@@ -713,6 +713,19 @@ std::pair<uWS::SocketContextOptions, bool> readOptionsObject(const FunctionCallb
713
713
return {options,true };
714
714
}
715
715
716
+ template <typename APP>
717
+ void uWS_App_adoptSocket (const FunctionCallbackInfo<Value> &args) {
718
+ APP *app = (APP *) args.Holder ()->GetAlignedPointerFromInternalField (0 );
719
+
720
+ Isolate *isolate = args.GetIsolate ();
721
+
722
+ int32_t fd = args[0 ]->Int32Value (isolate->GetCurrentContext ()).ToChecked ();
723
+
724
+ app->adoptSocket (fd);
725
+
726
+ args.GetReturnValue ().Set (args.Holder ());
727
+ }
728
+
716
729
template <typename APP>
717
730
void uWS_App_addChildApp (const FunctionCallbackInfo<Value> &args) {
718
731
APP *app = (APP *) args.Holder ()->GetAlignedPointerFromInternalField (0 );
@@ -971,7 +984,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
971
984
/* load balancing*/
972
985
appTemplate->PrototypeTemplate ()->Set (String::NewFromUtf8 (isolate," addChildAppDescriptor" , NewStringType::kNormal ).ToLocalChecked (),FunctionTemplate::New (isolate, uWS_App_addChildApp<APP>, args.Data ()));
973
986
appTemplate->PrototypeTemplate ()->Set (String::NewFromUtf8 (isolate," getDescriptor" , NewStringType::kNormal ).ToLocalChecked (),FunctionTemplate::New (isolate, uWS_App_getDescriptor<APP>, args.Data ()));
974
-
987
+ appTemplate-> PrototypeTemplate ()-> Set ( String::NewFromUtf8 (isolate, " adoptSocket " , NewStringType:: kNormal ). ToLocalChecked (), FunctionTemplate::New (isolate, uWS_App_adoptSocket<APP>, args. Data ()));
975
988
976
989
/* ws, listen*/
977
990
appTemplate->PrototypeTemplate ()->Set (String::NewFromUtf8 (isolate," ws" , NewStringType::kNormal ).ToLocalChecked (),FunctionTemplate::New (isolate, uWS_App_ws<APP>, args.Data ()));