本文整理汇总了C++中EventSource类的典型用法代码示例。如果您正苦于以下问题:C++ EventSource类的具体用法?C++ EventSource怎么用?C++ EventSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EventSource
EventSource* EventSource::create(ExecutionContext* context, const String& url, const EventSourceInit& eventSourceInit, ExceptionState& exceptionState)
{
if (url.isEmpty()) {
exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSource to an empty URL.");
return nullptr;
}
KURL fullURL = context->completeURL(url);
if (!fullURL.isValid()) {
exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSource to '" + url + "'. The URL is invalid.");
return nullptr;
}
// FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
if (!ContentSecurityPolicy::shouldBypassMainWorld(context) && !context->contentSecurityPolicy()->allowConnectToSource(fullURL)) {
// We can safely expose the URL to JavaScript, as this exception is generate synchronously before any redirects take place.
exceptionState.throwSecurityError("Refused to connect to '" + fullURL.elidedString() + "' because it violates the document's Content Security Policy.");
return nullptr;
}
EventSource* source = new EventSource(context, fullURL, eventSourceInit);
source->scheduleInitialConnect();
source->suspendIfNeeded();
return source;
}
示例2: EventSource
void RunLoop::PerformFunction(std::function<void ()> fn)
{
EventSource* ev = new EventSource([fn](EventSource& __e) {
fn();
});
AddEventSource(ev);
ev->Signal();
}
示例3: setJSEventSourceOnerror
void setJSEventSourceOnerror(ExecState* exec, JSObject* thisObject, JSValue value)
{
UNUSED_PARAM(exec);
EventSource* imp = static_cast<EventSource*>(static_cast<JSEventSource*>(thisObject)->impl());
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec);
if (!globalObject)
return;
imp->setOnerror(globalObject->createJSAttributeEventListener(value));
}
示例4: jsEventSourceOnerror
JSValue jsEventSourceOnerror(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
JSEventSource* castedThis = static_cast<JSEventSource*>(asObject(slot.slotBase()));
UNUSED_PARAM(exec);
EventSource* imp = static_cast<EventSource*>(castedThis->impl());
if (EventListener* listener = imp->onerror()) {
if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
return jsFunction;
}
return jsNull();
}
示例5: jsEventSourcePrototypeFunctionClose
JSValue JSC_HOST_CALL jsEventSourcePrototypeFunctionClose(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.inherits(&JSEventSource::s_info))
return throwError(exec, TypeError);
JSEventSource* castedThisObj = static_cast<JSEventSource*>(asObject(thisValue));
EventSource* imp = static_cast<EventSource*>(castedThisObj->impl());
imp->close();
return jsUndefined();
}
示例6: Impl
Impl( EventSource& output )
: _output( output )
{
for( uint8_t y = 0; y < 5; ++y )
output.add( Event( Vector3f( 0.f, y * 10.f, 0.f ),
VALUE_UNSET, 1.f ));
output.add( Event( Vector3f( 3.f, 5.f, 4.f ),
VALUE_UNSET, 1.f ));
output.add( Event( Vector3f( 5.f, 2.f, 1.f ),
VALUE_UNSET, 1.f ));
}
示例7: INC_STATS
v8::Handle<v8::Value> V8EventSource::addEventListenerCallback(const v8::Arguments& args)
{
INC_STATS("DOM.EventSource.addEventListener()");
EventSource* eventSource = V8EventSource::toNative(args.Holder());
RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(eventSource, args[1], false, ListenerFindOrCreate);
if (listener) {
String type = toWebCoreString(args[0]);
bool useCapture = args[2]->BooleanValue();
eventSource->addEventListener(type, listener, useCapture);
createHiddenDependency(args.Holder(), args[1], cacheIndex);
}
return v8::Undefined();
}
示例8: jsEventSourcePrototypeFunctionDispatchEvent
JSValue JSC_HOST_CALL jsEventSourcePrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.inherits(&JSEventSource::s_info))
return throwError(exec, TypeError);
JSEventSource* castedThisObj = static_cast<JSEventSource*>(asObject(thisValue));
EventSource* imp = static_cast<EventSource*>(castedThisObj->impl());
ExceptionCode ec = 0;
Event* evt = toEvent(args.at(0));
JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
setDOMException(exec, ec);
return result;
}
示例9: ASSERT
void WorkQueue::unregisterMachPortEventHandler(mach_port_t machPort)
{
ASSERT(machPort != MACH_PORT_NULL);
MutexLocker locker(m_eventSourcesMutex);
HashMap<mach_port_t, EventSource*>::iterator it = m_eventSources.find(machPort);
ASSERT(it != m_eventSources.end());
ASSERT(m_eventSources.contains(machPort));
EventSource* eventSource = it->second;
// Cancel and release the source. It will be deleted in its finalize handler.
dispatch_source_cancel(eventSource->dispatchSource());
dispatch_release(eventSource->dispatchSource());
m_eventSources.remove(it);
}
示例10: pull
void EventHandler::pull(EventSource& eventSource)
{
auto it=iters.find(eventSource.getID());
if(it!=iters.end())
{
eventSource.handlers.erase(it->second);
iters.erase(it);
}
}
示例11: NS_WARNING
// this method parses the characters as they become available instead of
// buffering them.
NS_METHOD
EventSource::StreamReaderFunc(nsIInputStream *aInputStream,
void *aClosure,
const char *aFromRawSegment,
uint32_t aToOffset,
uint32_t aCount,
uint32_t *aWriteCount)
{
EventSource* thisObject = static_cast<EventSource*>(aClosure);
if (!thisObject || !aWriteCount) {
NS_WARNING("EventSource cannot read from stream: no aClosure or aWriteCount");
return NS_ERROR_FAILURE;
}
*aWriteCount = 0;
int32_t srcCount, outCount;
PRUnichar out[2];
nsresult rv;
const char *p = aFromRawSegment,
*end = aFromRawSegment + aCount;
do {
srcCount = aCount - (p - aFromRawSegment);
outCount = 2;
thisObject->mLastConvertionResult =
thisObject->mUnicodeDecoder->Convert(p, &srcCount, out, &outCount);
MOZ_ASSERT(thisObject->mLastConvertionResult != NS_ERROR_ILLEGAL_INPUT);
for (int32_t i = 0; i < outCount; ++i) {
rv = thisObject->ParseCharacter(out[i]);
NS_ENSURE_SUCCESS(rv, rv);
}
p = p + srcCount;
} while (p < end &&
thisObject->mLastConvertionResult != NS_PARTIAL_MORE_INPUT &&
thisObject->mLastConvertionResult != NS_OK);
*aWriteCount = aCount;
return NS_OK;
}
示例12: LOG
EventSource* EventSource::create(const String& url, IEventSourceReceiver* receiver, const Hashtable<String,String>& eventSourceInit )
{
LOG(TRACE) + "Creating EventSource with URL: " + url;
if (url.empty()) {
return 0;
}
String fullUrl(
(url.find("://")==String::npos)?
(RHODESAPP().getCurrentUrl(-1) + url):
(url)
);
LOG(TRACE) + "Full URL for EventSource: " + fullUrl;
EventSource* source = new EventSource(fullUrl, receiver, eventSourceInit);
source->scheduleInitialConnect();
return source;
}
示例13: getEventRegion
bool EventSource::operator==(EventSource& xSource)
{
Rect * thisRegion = getEventRegion();
Rect * thatRegion = xSource.getEventRegion();
// If they are exactly in the same region, then they are the same.
// Current exceptions: Frame & Window.
if (thisRegion->m_x == thatRegion->m_x &&
thisRegion->m_y == thatRegion->m_y &&
thisRegion->m_width == thatRegion->m_width &&
thisRegion->m_height == thatRegion->m_height)
{
return true;
}
else
{
return false;
}
}
示例14: eventHandler
static void eventHandler(void* source)
{
EventSource* eventSource = static_cast<EventSource*>(source);
eventSource->m_function();
}
示例15: push
void EventHandler::push(EventSource& eventSource)
{
iters[eventSource.getID()]=eventSource.handlers.insert(eventSource.handlers.begin(), this);
}