@@ -28,6 +28,7 @@ uv_async_t async;
2828
2929//
3030Nan::Callback *emit_cb;
31+ Nan::CopyablePersistentTraits<v8::Object>::CopyablePersistent ctx_obj;
3132
3233// Message passing queue between OpenZWave callback and v8 async handler.
3334mutex zqueue_mutex;
@@ -136,7 +137,7 @@ void handleControllerCommand(NotifInfo *notif)
136137 info[2 ] = Nan::New<Integer>(notif->event ); // Driver::ControllerCommand
137138 info[3 ] = Nan::New<Integer>(notif->notification ); // Driver::ControllerCommand
138139 info[4 ] = Nan::New<String>(notif->help .c_str ()).ToLocalChecked ();
139- emit_cb->Call (5 , info);
140+ emit_cb->Call (Nan::New (ctx_obj), 5 , info);
140141}
141142// ##### END OF LEGACY MODE ###### //
142143#endif
@@ -170,7 +171,7 @@ void handleNotification(NotifInfo *notif)
170171 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
171172 emitinfo[2 ] = Nan::New<Integer>(value.GetCommandClassId ());
172173 emitinfo[3 ] = valobj;
173- emit_cb->Call (4 , emitinfo);
174+ emit_cb->Call (Nan::New (ctx_obj), 4 , emitinfo);
174175 break ;
175176 }
176177 // ##################
@@ -191,7 +192,7 @@ void handleNotification(NotifInfo *notif)
191192 emitinfo[2 ] = Nan::New<Integer>(value.GetCommandClassId ());
192193 emitinfo[3 ] = Nan::New<Integer>(value.GetInstance ());
193194 emitinfo[4 ] = Nan::New<Integer>(value.GetIndex ());
194- emit_cb->Call (5 , emitinfo);
195+ emit_cb->Call (Nan::New (ctx_obj), 5 , emitinfo);
195196 break ;
196197 }
197198 // ##################
@@ -203,7 +204,7 @@ void handleNotification(NotifInfo *notif)
203204 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
204205 emitinfo[2 ] = Nan::New<Integer>(value.GetCommandClassId ());
205206 emitinfo[3 ] = valobj;
206- emit_cb->Call (4 , emitinfo);
207+ emit_cb->Call (Nan::New (ctx_obj), 4 , emitinfo);
207208 break ;
208209 }
209210 // ####################
@@ -215,7 +216,7 @@ void handleNotification(NotifInfo *notif)
215216 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
216217 emitinfo[2 ] = Nan::New<Integer>(value.GetCommandClassId ());
217218 emitinfo[3 ] = valobj;
218- emit_cb->Call (4 , emitinfo);
219+ emit_cb->Call (Nan::New (ctx_obj), 4 , emitinfo);
219220 break ;
220221 }
221222 // #############
@@ -241,7 +242,7 @@ void handleNotification(NotifInfo *notif)
241242 }
242243 emitinfo[0 ] = Nan::New<String>(" node added" ).ToLocalChecked ();
243244 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
244- emit_cb->Call (2 , emitinfo);
245+ emit_cb->Call (Nan::New (ctx_obj), 2 , emitinfo);
245246 break ;
246247 }
247248 // #################
@@ -253,7 +254,7 @@ void handleNotification(NotifInfo *notif)
253254 }
254255 emitinfo[0 ] = Nan::New<String>(" node removed" ).ToLocalChecked ();
255256 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
256- emit_cb->Call (2 , emitinfo);
257+ emit_cb->Call (Nan::New (ctx_obj), 2 , emitinfo);
257258 break ;
258259 }
259260 // ######################
@@ -272,7 +273,7 @@ void handleNotification(NotifInfo *notif)
272273 emitinfo[0 ] = Nan::New<String>(" node naming" ).ToLocalChecked ();
273274 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
274275 emitinfo[2 ] = cbinfo;
275- emit_cb->Call (3 , emitinfo);
276+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
276277 break ;
277278 }
278279 // ###############
@@ -282,7 +283,7 @@ void handleNotification(NotifInfo *notif)
282283 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
283284 emitinfo[2 ] = Nan::New<Integer>(notif->event );
284285 emitinfo[3 ] = Nan::New<String>(notif->help .c_str ()).ToLocalChecked ();
285- emit_cb->Call (4 , emitinfo);
286+ emit_cb->Call (Nan::New (ctx_obj), 4 , emitinfo);
286287 break ;
287288 }
288289 // #####################
@@ -292,7 +293,7 @@ void handleNotification(NotifInfo *notif)
292293 node->polled = false ;
293294 emitinfo[0 ] = Nan::New<String>(" polling disabled" ).ToLocalChecked ();
294295 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
295- emit_cb->Call (2 , emitinfo);
296+ emit_cb->Call (Nan::New (ctx_obj), 2 , emitinfo);
296297 }
297298 break ;
298299 }
@@ -303,7 +304,7 @@ void handleNotification(NotifInfo *notif)
303304 node->polled = true ;
304305 emitinfo[0 ] = Nan::New<String>(" polling enabled" ).ToLocalChecked ();
305306 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
306- emit_cb->Call (2 , emitinfo);
307+ emit_cb->Call (Nan::New (ctx_obj), 2 , emitinfo);
307308 }
308309 break ;
309310 }
@@ -313,7 +314,7 @@ void handleNotification(NotifInfo *notif)
313314 emitinfo[0 ] = Nan::New<String>(" scene event" ).ToLocalChecked ();
314315 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
315316 emitinfo[2 ] = Nan::New<Integer>(notif->sceneid );
316- emit_cb->Call (3 , emitinfo);
317+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
317318 break ;
318319 }
319320 // ##################
@@ -322,7 +323,7 @@ void handleNotification(NotifInfo *notif)
322323 emitinfo[0 ] = Nan::New<String>(" create button" ).ToLocalChecked ();
323324 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
324325 emitinfo[2 ] = Nan::New<Integer>(notif->buttonid );
325- emit_cb->Call (3 , emitinfo);
326+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
326327 break ;
327328 }
328329 // ##################
@@ -331,7 +332,7 @@ void handleNotification(NotifInfo *notif)
331332 emitinfo[0 ] = Nan::New<String>(" delete button" ).ToLocalChecked ();
332333 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
333334 emitinfo[2 ] = Nan::New<Integer>(notif->buttonid );
334- emit_cb->Call (3 , emitinfo);
335+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
335336 break ;
336337 }
337338 // ##############
@@ -340,7 +341,7 @@ void handleNotification(NotifInfo *notif)
340341 emitinfo[0 ] = Nan::New<String>(" button on" ).ToLocalChecked ();
341342 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
342343 emitinfo[2 ] = Nan::New<Integer>(notif->buttonid );
343- emit_cb->Call (3 , emitinfo);
344+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
344345 break ;
345346 }
346347 // ###############
@@ -349,7 +350,7 @@ void handleNotification(NotifInfo *notif)
349350 emitinfo[0 ] = Nan::New<String>(" button off" ).ToLocalChecked ();
350351 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
351352 emitinfo[2 ] = Nan::New<Integer>(notif->buttonid );
352- emit_cb->Call (3 , emitinfo);
353+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
353354 break ;
354355 }
355356 // #################
@@ -359,14 +360,14 @@ void handleNotification(NotifInfo *notif)
359360 homeid = notif->homeid ;
360361 emitinfo[0 ] = Nan::New<String>(" driver ready" ).ToLocalChecked ();
361362 emitinfo[1 ] = Nan::New<Integer>(homeid);
362- emit_cb->Call (2 , emitinfo);
363+ emit_cb->Call (Nan::New (ctx_obj), 2 , emitinfo);
363364 break ;
364365 }
365366 // ##################
366367 case OpenZWave::Notification::Type_DriverFailed: {
367368 // ##################
368369 emitinfo[0 ] = Nan::New<String>(" driver failed" ).ToLocalChecked ();
369- emit_cb->Call (1 , emitinfo);
370+ emit_cb->Call (Nan::New (ctx_obj), 1 , emitinfo);
370371 break ;
371372 }
372373 // ##################################
@@ -376,7 +377,7 @@ void handleNotification(NotifInfo *notif)
376377 emitinfo[0 ] = Nan::New<String>(" node available" ).ToLocalChecked ();
377378 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
378379 emitinfo[2 ] = cbinfo;
379- emit_cb->Call (3 , emitinfo);
380+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
380381 break ;
381382 }
382383 /*
@@ -389,7 +390,7 @@ void handleNotification(NotifInfo *notif)
389390 emitinfo[0 ] = Nan::New<String>(" node ready" ).ToLocalChecked ();
390391 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
391392 emitinfo[2 ] = cbinfo;
392- emit_cb->Call (3 , emitinfo);
393+ emit_cb->Call (Nan::New (ctx_obj), 3 , emitinfo);
393394 break ;
394395 }
395396 /*
@@ -402,7 +403,7 @@ void handleNotification(NotifInfo *notif)
402403 case OpenZWave::Notification::Type_AllNodesQueriedSomeDead: {
403404 // #############################
404405 emitinfo[0 ] = Nan::New<String>(" scan complete" ).ToLocalChecked ();
405- emit_cb->Call (1 , emitinfo);
406+ emit_cb->Call (Nan::New (ctx_obj), 1 , emitinfo);
406407 break ;
407408 }
408409 // ##################
@@ -412,7 +413,7 @@ void handleNotification(NotifInfo *notif)
412413 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
413414 emitinfo[2 ] = Nan::New<Integer>(notif->notification );
414415 emitinfo[3 ] = Nan::New<String>(notif->help .c_str ()).ToLocalChecked ();
415- emit_cb->Call (4 , emitinfo);
416+ emit_cb->Call (Nan::New (ctx_obj), 4 , emitinfo);
416417 break ;
417418 }
418419 case OpenZWave::Notification::Type_DriverRemoved:
@@ -431,15 +432,15 @@ void handleNotification(NotifInfo *notif)
431432 emitinfo[3 ] =
432433 Nan::New<Integer>(notif->notification ); // Driver::ControllerState
433434 emitinfo[4 ] = Nan::New<String>(notif->help .c_str ()).ToLocalChecked ();
434- emit_cb->Call (5 , emitinfo);
435+ emit_cb->Call (Nan::New (ctx_obj), 5 , emitinfo);
435436 break ;
436437 case OpenZWave::Notification::Type_NodeReset:
437438 emitinfo[0 ] = Nan::New<String>(" node reset" ).ToLocalChecked ();
438439 emitinfo[1 ] = Nan::New<Integer>(notif->nodeid );
439440 emitinfo[2 ] = Nan::New<Integer>(notif->event ); // Driver::ControllerCommand
440441 emitinfo[3 ] =
441442 Nan::New<Integer>(notif->notification ); // Driver::ControllerState
442- emit_cb->Call (4 , emitinfo);
443+ emit_cb->Call (Nan::New (ctx_obj), 4 , emitinfo);
443444 break ;
444445#endif
445446 default :
0 commit comments