本文整理汇总了C++中JSWebSocket类的典型用法代码示例。如果您正苦于以下问题:C++ JSWebSocket类的具体用法?C++ JSWebSocket怎么用?C++ JSWebSocket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSWebSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jsWebSocketBufferedAmount
JSValue jsWebSocketBufferedAmount(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slot.slotBase()));
UNUSED_PARAM(exec);
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
return jsNumber(exec, imp->bufferedAmount());
}
示例2: setJSWebSocketOnclose
void setJSWebSocketOnclose(ExecState* exec, JSObject* thisObject, JSValue value)
{
UNUSED_PARAM(exec);
JSWebSocket* castedThis = static_cast<JSWebSocket*>(thisObject);
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
imp->setOnclose(createJSAttributeEventListener(exec, value, thisObject));
}
示例3: jsWebSocketPrototypeFunctionRemoveEventListener
JSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.inherits(&JSWebSocket::s_info))
return throwError(exec, TypeError);
JSWebSocket* castedThisObj = static_cast<JSWebSocket*>(asObject(thisValue));
return castedThisObj->removeEventListener(exec, args);
}
示例4: jsWebSocketBufferedAmount
JSValue jsWebSocketBufferedAmount(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase));
UNUSED_PARAM(exec);
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
JSValue result = jsNumber(imp->bufferedAmount());
return result;
}
示例5: jsWebSocketURL
JSValue jsWebSocketURL(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase));
UNUSED_PARAM(exec);
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
JSValue result = jsString(exec, imp->url());
return result;
}
示例6: isReachableFromOpaqueRoots
bool JSWebSocketOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
JSWebSocket* jsWebSocket = static_cast<JSWebSocket*>(handle.get().asCell());
if (jsWebSocket->impl()->hasPendingActivity())
return true;
if (!isObservable(jsWebSocket))
return false;
UNUSED_PARAM(visitor);
return false;
}
示例7: jsWebSocketPrototypeFunctionClose
JSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionClose(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.inherits(&JSWebSocket::s_info))
return throwError(exec, TypeError);
JSWebSocket* castedThisObj = static_cast<JSWebSocket*>(asObject(thisValue));
WebSocket* imp = static_cast<WebSocket*>(castedThisObj->impl());
imp->close();
return jsUndefined();
}
示例8: jsWebSocketOnclose
JSValue jsWebSocketOnclose(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slot.slotBase()));
UNUSED_PARAM(exec);
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
if (EventListener* listener = imp->onclose()) {
if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
return jsFunction;
}
return jsNull();
}
示例9: jsWebSocketPrototypeFunctionClose
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionClose(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSWebSocket::s_info))
return throwVMTypeError(exec);
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue));
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
imp->close();
return JSValue::encode(jsUndefined());
}
示例10: jsWebSocketPrototypeFunctionRemoveEventListener
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionRemoveEventListener(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSWebSocket::s_info))
return throwVMTypeError(exec);
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue));
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
JSValue listener = exec->argument(1);
if (!listener.isObject())
return JSValue::encode(jsUndefined());
imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
return JSValue::encode(jsUndefined());
}
示例11: jsWebSocketOnclose
JSValue jsWebSocketOnclose(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase));
UNUSED_PARAM(exec);
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
if (EventListener* listener = imp->onclose()) {
if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
return jsFunction;
}
}
return jsNull();
}
示例12: jsWebSocketPrototypeFunctionDispatchEvent
JSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.inherits(&JSWebSocket::s_info))
return throwError(exec, TypeError);
JSWebSocket* castedThisObj = static_cast<JSWebSocket*>(asObject(thisValue));
WebSocket* imp = static_cast<WebSocket*>(castedThisObj->impl());
ExceptionCode ec = 0;
Event* evt = toEvent(args.at(0));
JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
setDOMException(exec, ec);
return result;
}
示例13: jsWebSocketPrototypeFunctionDispatchEvent
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionDispatchEvent(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSWebSocket::s_info))
return throwVMTypeError(exec);
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue));
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
ExceptionCode ec = 0;
Event* evt(toEvent(exec->argument(0)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
setDOMException(exec, ec);
return JSValue::encode(result);
}
示例14: jsWebSocketPrototypeFunctionSend
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionSend(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSWebSocket::s_info))
return throwVMTypeError(exec);
JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue));
WebSocket* imp = static_cast<WebSocket*>(castedThis->impl());
if (exec->argumentCount() < 1)
return JSValue::encode(jsUndefined());
ExceptionCode ec = 0;
const String& data(ustringToString(exec->argument(0).toString(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
JSC::JSValue result = jsBoolean(imp->send(data, ec));
setDOMException(exec, ec);
return JSValue::encode(result);
}
示例15: finalize
void JSWebSocketOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
JSWebSocket* jsWebSocket = static_cast<JSWebSocket*>(handle.get().asCell());
DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, jsWebSocket->impl(), jsWebSocket);
}