Skip to content

Commit 9ae7df5

Browse files
committed
Wrap removeChildApp
1 parent 6fb88f7 commit 9ae7df5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/AppWrapper.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,22 @@ void uWS_App_adoptSocket(const FunctionCallbackInfo<Value> &args) {
726726
args.GetReturnValue().Set(args.Holder());
727727
}
728728

729+
template <typename APP>
730+
void uWS_App_removeChildApp(const FunctionCallbackInfo<Value> &args) {
731+
APP *app = (APP *) args.Holder()->GetAlignedPointerFromInternalField(0);
732+
733+
Isolate *isolate = args.GetIsolate();
734+
735+
double descriptor = args[0]->NumberValue(isolate->GetCurrentContext()).ToChecked();
736+
737+
APP *receivingApp;
738+
memcpy(&receivingApp, &descriptor, sizeof(receivingApp));
739+
740+
app->removeChildApp(receivingApp);
741+
742+
args.GetReturnValue().Set(args.Holder());
743+
}
744+
729745
template <typename APP>
730746
void uWS_App_addChildApp(const FunctionCallbackInfo<Value> &args) {
731747
APP *app = (APP *) args.Holder()->GetAlignedPointerFromInternalField(0);
@@ -982,6 +998,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
982998
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "filter", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_filter<APP>, args.Data()));
983999

9841000
/* load balancing */
1001+
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "removeChildAppDescriptor", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_removeChildApp<APP>, args.Data()));
9851002
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "addChildAppDescriptor", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_addChildApp<APP>, args.Data()));
9861003
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getDescriptor", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_getDescriptor<APP>, args.Data()));
9871004
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "adoptSocket", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_adoptSocket<APP>, args.Data()));

0 commit comments

Comments
 (0)