Port to Node.js 10, 11 and 12
This commit is contained in:
parent
3f00f89ee6
commit
f4bc7b38d1
5 changed files with 27 additions and 27 deletions
|
@ -28,13 +28,13 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
Local<Object> behaviorObject = Local<Object>::Cast(args[1]);
|
||||
|
||||
/* maxPayloadLength */
|
||||
behavior.maxPayloadLength = behaviorObject->Get(String::NewFromUtf8(isolate, "maxPayloadLength"))->Int32Value();
|
||||
behavior.maxPayloadLength = behaviorObject->Get(String::NewFromUtf8(isolate, "maxPayloadLength"))->Int32Value(isolate->GetCurrentContext()).ToChecked();
|
||||
|
||||
/* idleTimeout */
|
||||
behavior.idleTimeout = behaviorObject->Get(String::NewFromUtf8(isolate, "idleTimeout"))->Int32Value();
|
||||
behavior.idleTimeout = behaviorObject->Get(String::NewFromUtf8(isolate, "idleTimeout"))->Int32Value(isolate->GetCurrentContext()).ToChecked();
|
||||
|
||||
/* Compression, map from 0, 1, 2 to disabled, shared, dedicated. This is actually the enum */
|
||||
behavior.compression = (uWS::CompressOptions) behaviorObject->Get(String::NewFromUtf8(isolate, "compression"))->Int32Value();
|
||||
behavior.compression = (uWS::CompressOptions) behaviorObject->Get(String::NewFromUtf8(isolate, "compression"))->Int32Value(isolate->GetCurrentContext()).ToChecked();
|
||||
|
||||
/* Open */
|
||||
openPf.Reset(args.GetIsolate(), Local<Function>::Cast(behaviorObject->Get(String::NewFromUtf8(isolate, "open"))));
|
||||
|
@ -66,7 +66,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
Local<Function> openLf = Local<Function>::New(isolate, openPf);
|
||||
if (!openLf->IsUndefined()) {
|
||||
Local<Value> argv[] = {wsObject, reqObject};
|
||||
openLf->Call(isolate->GetCurrentContext()->Global(), 2, argv);
|
||||
openLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -81,7 +81,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
Local<Value> argv[3] = {Local<Object>::New(isolate, *(perSocketData->socketPf)),
|
||||
messageArrayBuffer,
|
||||
Boolean::New(isolate, opCode == uWS::OpCode::BINARY)};
|
||||
Local<Function>::New(isolate, messagePf)->Call(isolate->GetCurrentContext()->Global(), 3, argv);
|
||||
Local<Function>::New(isolate, messagePf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv);
|
||||
|
||||
/* Important: we clear the ArrayBuffer to make sure it is not invalidly used after return */
|
||||
messageArrayBuffer->Neuter();
|
||||
|
@ -96,7 +96,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
PerSocketData *perSocketData = (PerSocketData *) ws->getUserData();
|
||||
Local<Value> argv[1] = {Local<Object>::New(isolate, *(perSocketData->socketPf))
|
||||
};
|
||||
Local<Function>::New(isolate, drainPf)->Call(isolate->GetCurrentContext()->Global(), 1, argv);
|
||||
Local<Function>::New(isolate, drainPf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
Local<Function> closeLf = Local<Function>::New(isolate, closePf);
|
||||
if (!closeLf->IsUndefined()) {
|
||||
Local<Value> argv[3] = {wsObject, Integer::New(isolate, code), messageArrayBuffer};
|
||||
closeLf->Call(isolate->GetCurrentContext()->Global(), 3, argv);
|
||||
closeLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv);
|
||||
}
|
||||
|
||||
delete perSocketData->socketPf;
|
||||
|
@ -163,7 +163,7 @@ void uWS_App_get(F f, const FunctionCallbackInfo<Value> &args) {
|
|||
reqObject->SetAlignedPointerInInternalField(0, req);
|
||||
|
||||
Local<Value> argv[] = {resObject, reqObject};
|
||||
Local<Function>::New(isolate, *pf)->Call(isolate->GetCurrentContext()->Global(), 2, argv);
|
||||
Local<Function>::New(isolate, *pf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv);
|
||||
|
||||
/* Properly invalidate req */
|
||||
reqObject->SetAlignedPointerInInternalField(0, nullptr);
|
||||
|
@ -190,7 +190,7 @@ void uWS_App_listen(const FunctionCallbackInfo<Value> &args) {
|
|||
auto cb = [&args](auto *token) {
|
||||
/* Return a false boolean if listen failed */
|
||||
Local<Value> argv[] = {token ? Local<Value>::Cast(External::New(isolate, token)) : Local<Value>::Cast(Boolean::New(isolate, false))};
|
||||
Local<Function>::Cast(args[args.Length() - 1])->Call(isolate->GetCurrentContext()->Global(), 1, argv);
|
||||
Local<Function>::Cast(args[args.Length() - 1])->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv);
|
||||
};
|
||||
|
||||
/* Host is first, if present */
|
||||
|
@ -277,7 +277,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
|||
}
|
||||
|
||||
/* ssl_prefer_low_memory_usage */
|
||||
ssl_options.ssl_prefer_low_memory_usage = Local<Object>::Cast(args[0])->Get(String::NewFromUtf8(isolate, "ssl_prefer_low_memory_usage"))->BooleanValue();
|
||||
ssl_options.ssl_prefer_low_memory_usage = Local<Object>::Cast(args[0])->Get(String::NewFromUtf8(isolate, "ssl_prefer_low_memory_usage"))->BooleanValue(isolate->GetCurrentContext()).ToChecked();
|
||||
}
|
||||
|
||||
app = new APP(ssl_options);
|
||||
|
@ -341,7 +341,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
|
|||
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "ws"), FunctionTemplate::New(isolate, uWS_App_ws<APP>));
|
||||
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "listen"), FunctionTemplate::New(isolate, uWS_App_listen<APP>));
|
||||
|
||||
Local<Object> localApp = appTemplate->GetFunction()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
Local<Object> localApp = appTemplate->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
localApp->SetAlignedPointerInInternalField(0, app);
|
||||
|
||||
/* Add this to our delete list */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue