Wrap and document unsubscribeAll, ping
This commit is contained in:
parent
2db5895dd7
commit
a604881448
12 changed files with 169 additions and 86 deletions
|
@ -121,7 +121,7 @@ struct WebSocketWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
/* Takes message, isBinary. Returns true on success, false otherwise */
|
||||
/* Takes message, isBinary, compressed. Returns true on success, false otherwise */
|
||||
template <bool SSL>
|
||||
static void uWS_WebSocket_send(const FunctionCallbackInfo<Value> &args) {
|
||||
Isolate *isolate = args.GetIsolate();
|
||||
|
@ -138,8 +138,26 @@ struct WebSocketWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
/* Takes message. Returns true on success, false otherwise */
|
||||
template <bool SSL>
|
||||
static void uWS_WebSocket_ping(const FunctionCallbackInfo<Value> &args) {
|
||||
Isolate *isolate = args.GetIsolate();
|
||||
auto *ws = getWebSocket<SSL>(args);
|
||||
if (ws) {
|
||||
NativeString message(args.GetIsolate(), args[0]);
|
||||
if (message.isInvalid(args)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a wrapper that does not exist in the C++ project */
|
||||
bool ok = ws->send(message.getString(), uWS::OpCode::PING);
|
||||
|
||||
args.GetReturnValue().Set(Boolean::New(isolate, ok));
|
||||
}
|
||||
}
|
||||
|
||||
/* Takes nothing, returns this */
|
||||
/*template <bool SSL>
|
||||
template <bool SSL>
|
||||
static void uWS_WebSocket_unsubscribeAll(const FunctionCallbackInfo<Value> &args) {
|
||||
Isolate *isolate = args.GetIsolate();
|
||||
auto *ws = getWebSocket<SSL>(args);
|
||||
|
@ -147,7 +165,7 @@ struct WebSocketWrapper {
|
|||
ws->unsubscribeAll();
|
||||
args.GetReturnValue().Set(args.Holder());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/* Takes function, returns this */
|
||||
template <bool SSL>
|
||||
|
@ -184,8 +202,9 @@ struct WebSocketWrapper {
|
|||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "subscribe", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_subscribe<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "unsubscribe", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_unsubscribe<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "publish", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_publish<SSL>));
|
||||
//wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "unsubscribeAll", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_unsubscribeAll<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "unsubscribeAll", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_unsubscribeAll<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "cork", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_cork<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "ping", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_ping<SSL>));
|
||||
|
||||
/* Create the template */
|
||||
Local<Object> wsObjectLocal = wsTemplateLocal->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue