Skip to content

Commit

Permalink
Wrap adoptSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Aug 28, 2024
1 parent c067109 commit 6fb88f7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/AppWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,19 @@ std::pair<uWS::SocketContextOptions, bool> readOptionsObject(const FunctionCallb
return {options, true};
}

template <typename APP>
void uWS_App_adoptSocket(const FunctionCallbackInfo<Value> &args) {
APP *app = (APP *) args.Holder()->GetAlignedPointerFromInternalField(0);

Isolate *isolate = args.GetIsolate();

int32_t fd = args[0]->Int32Value(isolate->GetCurrentContext()).ToChecked();

app->adoptSocket(fd);

args.GetReturnValue().Set(args.Holder());
}

template <typename APP>
void uWS_App_addChildApp(const FunctionCallbackInfo<Value> &args) {
APP *app = (APP *) args.Holder()->GetAlignedPointerFromInternalField(0);
Expand Down Expand Up @@ -971,7 +984,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
/* load balancing */
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "addChildAppDescriptor", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_addChildApp<APP>, args.Data()));
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getDescriptor", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_getDescriptor<APP>, args.Data()));

appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "adoptSocket", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_adoptSocket<APP>, args.Data()));

/* ws, listen */
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "ws", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_ws<APP>, args.Data()));
Expand Down

0 comments on commit 6fb88f7

Please sign in to comment.