Support Node.js 14
This commit is contained in:
parent
83bee418d2
commit
bd9007eee0
4 changed files with 15 additions and 4 deletions
|
@ -114,7 +114,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
CallJS(isolate, Local<Function>::New(isolate, messagePf), 3, argv);
|
||||
|
||||
/* Important: we clear the ArrayBuffer to make sure it is not invalidly used after return */
|
||||
messageArrayBuffer->Neuter();
|
||||
NeuterArrayBuffer(messageArrayBuffer);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
delete perSocketData->socketPf;
|
||||
|
||||
/* Again, here we clear the buffer to avoid strange bugs */
|
||||
messageArrayBuffer->Neuter();
|
||||
NeuterArrayBuffer(messageArrayBuffer);
|
||||
};
|
||||
|
||||
app->template ws<PerSocketData>(std::string(pattern.getString()), std::move(behavior));
|
||||
|
|
|
@ -49,7 +49,7 @@ struct HttpResponseWrapper {
|
|||
Local<Value> argv[] = {dataArrayBuffer, Boolean::New(isolate, last)};
|
||||
CallJS(isolate, Local<Function>::New(isolate, p), 2, argv);
|
||||
|
||||
dataArrayBuffer->Neuter();
|
||||
NeuterArrayBuffer(dataArrayBuffer);
|
||||
});
|
||||
|
||||
args.GetReturnValue().Set(args.Holder());
|
||||
|
|
|
@ -40,6 +40,16 @@ bool BooleanValue(Isolate *isolate, Local<Value> value) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void NeuterArrayBuffer(Local<ArrayBuffer> ab) {
|
||||
#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
|
||||
/* Old */
|
||||
ab->Neuter();
|
||||
#else
|
||||
/* Node.js 12, 13 */
|
||||
ab->Detach();
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "Utilities.h"
|
||||
#include "WebSocketWrapper.h"
|
||||
#include "HttpResponseWrapper.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue