Skip to content

Commit

Permalink
fix: Emit disconnect event when Zigate unplugged (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
yateeshc authored Aug 24, 2023
1 parent 9597a0a commit 79f3e38
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/adapter/zigate/adapter/zigateAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ZiGateAdapter extends Adapter {
this.driver.on('receivedRaw', this.rawDataListener.bind(this));
this.driver.on('LeaveIndication', this.leaveIndicationListener.bind(this));
this.driver.on('DeviceAnnounce', this.deviceAnnounceListener.bind(this));
this.driver.on('close', this.onZiGateClose.bind(this));
}

/**
Expand Down Expand Up @@ -798,6 +799,13 @@ class ZiGateAdapter extends Adapter {
matcher.commandIdentifier === payload.frame.Header.commandIdentifier &&
matcher.direction === payload.frame.Header.frameControl.direction;
}

private onZiGateClose(): void {
if (!this.closing) {
this.emit(Events.Events.disconnected);
}
}

}

export default ZiGateAdapter;

0 comments on commit 79f3e38

Please sign in to comment.