@@ -28,14 +28,15 @@ Napi::FunctionReference osn::Service::constructor;
28
28
Napi::Object osn::Service::Init (Napi::Env env, Napi::Object exports)
29
29
{
30
30
Napi::HandleScope scope (env);
31
- Napi::Function func = DefineClass (
32
- env, " Service" ,
33
- {StaticMethod (" types" , &osn::Service::Types), StaticMethod (" create" , &osn::Service::Create), InstanceMethod (" update" , &osn::Service::Update),
31
+ Napi::Function func =
32
+ DefineClass (env, " Service" ,
33
+ {StaticMethod (" types" , &osn::Service::Types), StaticMethod (" destroy" , &osn::Service::Destroy),
34
+ StaticMethod (" create" , &osn::Service::Create), InstanceMethod (" update" , &osn::Service::Update),
34
35
35
- InstanceAccessor (" name" , &osn::Service::GetName, nullptr ), InstanceAccessor (" properties" , &osn::Service::GetProperties, nullptr ),
36
- InstanceAccessor (" settings" , &osn::Service::GetSettings, nullptr ),
36
+ InstanceAccessor (" name" , &osn::Service::GetName, nullptr ), InstanceAccessor (" properties" , &osn::Service::GetProperties, nullptr ),
37
+ InstanceAccessor (" settings" , &osn::Service::GetSettings, nullptr ),
37
38
38
- StaticAccessor (" legacySettings" , &osn::Service::GetLegacySettings, &osn::Service::SetLegacySettings)});
39
+ StaticAccessor (" legacySettings" , &osn::Service::GetLegacySettings, &osn::Service::SetLegacySettings)});
39
40
exports.Set (" Service" , func);
40
41
osn::Service::constructor = Napi::Persistent (func);
41
42
osn::Service::constructor.SuppressDestruct ();
@@ -127,6 +128,23 @@ Napi::Value osn::Service::Create(const Napi::CallbackInfo &info)
127
128
return instance;
128
129
}
129
130
131
+ void osn::Service::Destroy (const Napi::CallbackInfo &info)
132
+ {
133
+ if (info.Length () != 1 )
134
+ return ;
135
+
136
+ auto service = Napi::ObjectWrap<osn::Service>::Unwrap (info[0 ].ToObject ());
137
+
138
+ auto conn = GetConnection (info);
139
+ if (!conn)
140
+ return ;
141
+
142
+ std::vector<ipc::value> response = conn->call_synchronous_helper (" Service" , " Destroy" , {ipc::value (service->uid )});
143
+
144
+ if (!ValidateResponse (info, response))
145
+ return ;
146
+ }
147
+
130
148
Napi::Value osn::Service::GetName (const Napi::CallbackInfo &info)
131
149
{
132
150
auto conn = GetConnection (info);
0 commit comments