Update to uWS v0.16.1, wrap app.publish

This commit is contained in:
Alex Hultman 2019-10-17 02:19:46 +02:00
parent ea8d4c784d
commit 97bff11ba0
2 changed files with 11 additions and 1 deletions

View File

@ -232,6 +232,15 @@ void uWS_App_listen(const FunctionCallbackInfo<Value> &args) {
args.GetReturnValue().Set(args.Holder());
}
template <typename APP>
void uWS_App_publish(const FunctionCallbackInfo<Value> &args) {
APP *app = (APP *) args.Holder()->GetAlignedPointerFromInternalField(0);
NativeString topic(isolate, args[0]);
NativeString message(isolate, args[1]);
app->publish(topic.getString(), message.getString(), args[2]->BooleanValue(isolate->GetCurrentContext()).ToChecked() ? uWS::OpCode::BINARY : uWS::OpCode::TEXT, args[3]->BooleanValue(isolate->GetCurrentContext()).ToChecked());
}
template <typename APP>
void uWS_App(const FunctionCallbackInfo<Value> &args) {
Local<FunctionTemplate> appTemplate = FunctionTemplate::New(isolate);
@ -356,6 +365,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
/* ws, listen */
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>));
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "publish"), FunctionTemplate::New(isolate, uWS_App_publish<APP>));
Local<Object> localApp = appTemplate->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
localApp->SetAlignedPointerInInternalField(0, app);

@ -1 +1 @@
Subproject commit d8fe3a25b8f81d71d13a4dc134846d49ce6529ba
Subproject commit 49f460ef208e88da3e23b5cadba8a2f952d0763b