Skip to content

Commit

Permalink
Wrap removeChildApp
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Sep 20, 2024
1 parent 6fb88f7 commit 9ae7df5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/AppWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,22 @@ void uWS_App_adoptSocket(const FunctionCallbackInfo<Value> &args) {
args.GetReturnValue().Set(args.Holder());
}

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

Isolate *isolate = args.GetIsolate();

double descriptor = args[0]->NumberValue(isolate->GetCurrentContext()).ToChecked();

APP *receivingApp;
memcpy(&receivingApp, &descriptor, sizeof(receivingApp));

app->removeChildApp(receivingApp);

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 @@ -982,6 +998,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "filter", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_filter<APP>, args.Data()));

/* load balancing */
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "removeChildAppDescriptor", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_removeChildApp<APP>, args.Data()));
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()));
Expand Down

0 comments on commit 9ae7df5

Please sign in to comment.