forked from LeenkxTeam/LNXRNT
Cleanup bindings and viewport
This commit is contained in:
@ -2766,24 +2766,6 @@ static void WebSocketClose(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
}
|
||||
|
||||
void createWebSocketClass(Isolate* isolate, Local<ObjectTemplate>& global) {
|
||||
Local<FunctionTemplate> wsTpl = FunctionTemplate::New(isolate, WebSocketConstructor);
|
||||
wsTpl->SetClassName(String::NewFromUtf8(isolate, "WebSocket").ToLocalChecked());
|
||||
wsTpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
Local<ObjectTemplate> proto = wsTpl->PrototypeTemplate();
|
||||
proto->Set(isolate, "send", FunctionTemplate::New(isolate, WebSocketSend));
|
||||
proto->Set(isolate, "close", FunctionTemplate::New(isolate, WebSocketClose));
|
||||
|
||||
Local<Function> wsFunc = wsTpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
wsFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "CONNECTING").ToLocalChecked(), Integer::New(isolate, 0));
|
||||
wsFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "OPEN").ToLocalChecked(), Integer::New(isolate, 1));
|
||||
wsFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "CLOSING").ToLocalChecked(), Integer::New(isolate, 2));
|
||||
wsFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "CLOSED").ToLocalChecked(), Integer::New(isolate, 3));
|
||||
|
||||
global->Set(isolate, "WebSocket", wsTpl);
|
||||
}
|
||||
|
||||
static void EventConstructor(const FunctionCallbackInfo<Value>& args) {
|
||||
Isolate* isolate = args.GetIsolate();
|
||||
HandleScope scope(isolate);
|
||||
@ -2887,4 +2869,32 @@ void createWebSocketEventClasses(Isolate* isolate, Local<ObjectTemplate>& global
|
||||
global->Set(isolate, "CloseEvent", closeEventTpl);
|
||||
}
|
||||
|
||||
void bind_websocket_class(Isolate* isolate, const Global<Context>& context) {
|
||||
WebSocketWrapper::initialize();
|
||||
|
||||
Locker locker{isolate};
|
||||
Isolate::Scope isolate_scope(isolate);
|
||||
HandleScope handle_scope(isolate);
|
||||
|
||||
Local<Context> current_context = Local<Context>::New(isolate, context);
|
||||
Context::Scope context_scope(current_context);
|
||||
Local<Object> global = current_context->Global();
|
||||
|
||||
Local<FunctionTemplate> wsTpl = FunctionTemplate::New(isolate, WebSocketConstructor);
|
||||
wsTpl->SetClassName(String::NewFromUtf8(isolate, "WebSocket").ToLocalChecked());
|
||||
wsTpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
Local<ObjectTemplate> proto = wsTpl->PrototypeTemplate();
|
||||
proto->Set(isolate, "send", FunctionTemplate::New(isolate, WebSocketSend));
|
||||
proto->Set(isolate, "close", FunctionTemplate::New(isolate, WebSocketClose));
|
||||
|
||||
Local<Function> wsFunc = wsTpl->GetFunction(current_context).ToLocalChecked();
|
||||
wsFunc->Set(current_context, String::NewFromUtf8(isolate, "CONNECTING").ToLocalChecked(), Integer::New(isolate, 0));
|
||||
wsFunc->Set(current_context, String::NewFromUtf8(isolate, "OPEN").ToLocalChecked(), Integer::New(isolate, 1));
|
||||
wsFunc->Set(current_context, String::NewFromUtf8(isolate, "CLOSING").ToLocalChecked(), Integer::New(isolate, 2));
|
||||
wsFunc->Set(current_context, String::NewFromUtf8(isolate, "CLOSED").ToLocalChecked(), Integer::New(isolate, 3));
|
||||
|
||||
global->Set(current_context, String::NewFromUtf8(isolate, "WebSocket").ToLocalChecked(), wsFunc);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user