本文整理汇总了C++中EventSource::scheduleInitialConnect方法的典型用法代码示例。如果您正苦于以下问题:C++ EventSource::scheduleInitialConnect方法的具体用法?C++ EventSource::scheduleInitialConnect怎么用?C++ EventSource::scheduleInitialConnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventSource
的用法示例。
在下文中一共展示了EventSource::scheduleInitialConnect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
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: create
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;
}