mirror of
https://github.com/uNetworking/uWebSockets.js.git
synced 2026-04-06 20:00:24 -04:00
Merge userData with wsObject
This commit is contained in:
@@ -248,26 +248,17 @@ struct HttpResponseWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
/* Takes UserData, secKey, secProtocol, secExtensions, context. Returns nothing */
|
||||
template <bool SSL>
|
||||
static void res_upgrade(const FunctionCallbackInfo<Value> &args) {
|
||||
Isolate *isolate = args.GetIsolate();
|
||||
auto *res = getHttpResponse<SSL>(args);
|
||||
if (res) {
|
||||
|
||||
printf("Calling upgrade!\n");
|
||||
|
||||
/* We require exactly 5 arguments */
|
||||
if (args.Length() != 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* We are being passed userData (wsObject) */
|
||||
//Local<Object> wsObject = args[0];
|
||||
//Local<String> secWebSocketKey = args[1];
|
||||
//Local<String> secWebSocketProtocol = args[2];
|
||||
//Local<String> secWebSocketExtensions = args[3];
|
||||
//Local<External> context = args[4];
|
||||
|
||||
|
||||
NativeString secWebSocketKey(args.GetIsolate(), args[1]);
|
||||
if (secWebSocketKey.isInvalid(args)) {
|
||||
return;
|
||||
@@ -287,10 +278,11 @@ struct HttpResponseWrapper {
|
||||
|
||||
invalidateResObject(args);
|
||||
|
||||
/* This releases on return */
|
||||
UniquePersistent<Object> userData;
|
||||
userData.Reset(isolate, Local<Object>::Cast(args[0]));
|
||||
|
||||
printf("Upgrading now!\n");
|
||||
/* Immediately calls open handler */
|
||||
res->template upgrade<PerSocketData>({
|
||||
.socketPf = &userData
|
||||
}, secWebSocketKey.getString(), secWebSocketProtocol.getString(),
|
||||
|
||||
Reference in New Issue
Block a user