Update for API change: ws.end, ws.close

This commit is contained in:
Alex Hultman 2019-01-26 17:26:53 +01:00
parent c66e3836ad
commit 59662d7e07
3 changed files with 8 additions and 9 deletions

View File

@ -26,17 +26,17 @@ struct WebSocketWrapper {
/* Takes nothing returns nothing */ /* Takes nothing returns nothing */
template <bool SSL> template <bool SSL>
static void uWS_WebSocket_terminate(const FunctionCallbackInfo<Value> &args) { static void uWS_WebSocket_close(const FunctionCallbackInfo<Value> &args) {
auto *ws = getWebSocket<SSL>(args); auto *ws = getWebSocket<SSL>(args);
if (ws) { if (ws) {
invalidateWsObject(args); invalidateWsObject(args);
ws->terminate(); ws->close();
} }
} }
/* Takes code, message, returns undefined */ /* Takes code, message, returns undefined */
template <bool SSL> template <bool SSL>
static void uWS_WebSocket_close(const FunctionCallbackInfo<Value> &args) { static void uWS_WebSocket_end(const FunctionCallbackInfo<Value> &args) {
auto *ws = getWebSocket<SSL>(args); auto *ws = getWebSocket<SSL>(args);
if (ws) { if (ws) {
int code = 0; int code = 0;
@ -50,7 +50,7 @@ struct WebSocketWrapper {
} }
invalidateWsObject(args); invalidateWsObject(args);
ws->close(code, message.getString()); ws->end(code, message.getString());
} }
} }
@ -92,8 +92,8 @@ struct WebSocketWrapper {
/* Register our functions */ /* Register our functions */
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "send"), FunctionTemplate::New(isolate, uWS_WebSocket_send<SSL>)); wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "send"), FunctionTemplate::New(isolate, uWS_WebSocket_send<SSL>));
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "end"), FunctionTemplate::New(isolate, uWS_WebSocket_end<SSL>));
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "close"), FunctionTemplate::New(isolate, uWS_WebSocket_close<SSL>)); wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "close"), FunctionTemplate::New(isolate, uWS_WebSocket_close<SSL>));
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "terminate"), FunctionTemplate::New(isolate, uWS_WebSocket_terminate<SSL>));
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getBufferedAmount"), FunctionTemplate::New(isolate, uWS_WebSocket_getBufferedAmount<SSL>)); wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getBufferedAmount"), FunctionTemplate::New(isolate, uWS_WebSocket_getBufferedAmount<SSL>));
/* Create the template */ /* Create the template */

View File

@ -127,7 +127,7 @@ function performRandomServerAction(ws, uniform) {
switch (action) { switch (action) {
case 0: { case 0: {
ws.close(); ws.end();
break; break;
} }
case 1: { case 1: {
@ -142,8 +142,7 @@ function performRandomServerAction(ws, uniform) {
break; break;
} }
case 2: { case 2: {
/* This should correspond to hard us_socket_close */ ws.close();
ws.terminate();
break; break;
} }
} }

@ -1 +1 @@
Subproject commit ba10536f50bb5060cdaa0ce8725d506faa8ac1ce Subproject commit 7d990a3bc177271eb64af2f58c30a5253507fa7f