Example #1
0
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());
}
Example #2
0
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));
}
Example #3
0
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);
}
Example #4
0
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;
}
Example #5
0
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;
}
Example #6
0
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;
}
Example #7
0
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();
}
Example #8
0
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();
}
Example #9
0
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());
}
Example #10
0
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());
}
Example #11
0
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();
}
Example #12
0
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;
}
Example #13
0
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);
}
Example #14
0
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);
}
Example #15
0
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);
}
Example #16
0
JSValue jsWebSocketConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSWebSocket* domObject = static_cast<JSWebSocket*>(asObject(slotBase));
    return JSWebSocket::getConstructor(exec, domObject->globalObject());
}