Skip to content

Commit

Permalink
try get away other callback deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed May 9, 2024
1 parent cc8604d commit 9cce2e3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/mbus-master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,16 @@ NAN_METHOD(MbusMaster::Get) {

char *address = get(Nan::To<v8::String>(info[0]).ToLocalChecked(),"0");
bool ping_first = Nan::To<bool>(info[1]).FromJust();
Nan::Callback *callback = obj->connected ? new Nan::Callback(info[2].As<Function>()) : new Nan::Call(info[2].As<Function>());

if(obj->connected) {
obj->communicationInProgress = true;

Nan::Callback *callback = new Nan::Callback(info[2].As<Function>());
Nan::AsyncQueueWorker(new RecieveWorker(callback, address, ping_first, &(obj->queueLock), obj->handle, &(obj->communicationInProgress)));
} else {
Local<Value> argv[] = {
Nan::Error("Not connected to port")
};

Nan::Call *callback = new Nan::Call(info[2].As<Function>());
callback->Call(1, argv);
}
info.GetReturnValue().SetUndefined();
Expand Down Expand Up @@ -612,16 +610,15 @@ NAN_METHOD(MbusMaster::ScanSecondary) {

MbusMaster* obj = node::ObjectWrap::Unwrap<MbusMaster>(info.This());

Nan::Callback *callback = obj->connected ? new Nan::Callback(info[0].As<Function>()) : new Nan::Call(info[0].As<Function>());
if(obj->connected) {
obj->communicationInProgress = true;

Nan::Callback *callback = new Nan::Callback(info[0].As<Function>());
Nan::AsyncQueueWorker(new ScanSecondaryWorker(callback, &(obj->queueLock), obj->handle, &(obj->communicationInProgress)));
} else {
Local<Value> argv[] = {
Nan::Error("Not connected to port")
};
Nan::Call *callback = new Nan::Call(info[0].As<Function>());
callback->Call(1, argv);
}
info.GetReturnValue().SetUndefined();
Expand Down Expand Up @@ -800,16 +797,15 @@ NAN_METHOD(MbusMaster::SetPrimaryId) {

char *oldAddress = get(Nan::To<v8::String>(info[0]).ToLocalChecked(),"0");
int newAddress = (int)Nan::To<int64_t>(info[1]).FromJust();
Nan::Callback *callback = obj->connected ? new Nan::Callback(info[2].As<Function>()) : new Nan::Call(info[2].As<Function>());
if(obj->connected) {
obj->communicationInProgress = true;

Nan::Callback *callback = new Nan::Callback(info[2].As<Function>());
Nan::AsyncQueueWorker(new SetPrimaryWorker(callback, oldAddress, newAddress, &(obj->queueLock), obj->handle, &(obj->communicationInProgress)));
} else {
Local<Value> argv[] = {
Nan::Error("Not connected to port")
};
Nan::Call *callback = new Nan::Call(info[2].As<Function>());
callback->Call(1, argv);
}
info.GetReturnValue().SetUndefined();
Expand Down

0 comments on commit 9cce2e3

Please sign in to comment.