mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
use base class methods for disconnected event
This commit is contained in:
parent
c09ad0514c
commit
09ff8771d8
3 changed files with 6 additions and 2 deletions
|
|
@ -44,7 +44,7 @@ class BleConnection extends Connection {
|
|||
|
||||
// listen for ble disconnect
|
||||
this.bleDevice.addEventListener("gattserverdisconnected", () => {
|
||||
this.emit("disconnected");
|
||||
this.onDisconnected();
|
||||
});
|
||||
|
||||
// connect to gatt server
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ class Connection extends EventEmitter {
|
|||
this.emit("connected");
|
||||
}
|
||||
|
||||
onDisconnected() {
|
||||
this.emit("disconnected");
|
||||
}
|
||||
|
||||
async close() {
|
||||
throw new Error("This method must be implemented by the subclass.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class SerialConnection extends Connection {
|
|||
|
||||
// listen for disconnect
|
||||
this.serialPort.addEventListener("disconnect", () => {
|
||||
this.emit("disconnected");
|
||||
this.onDisconnected();
|
||||
});
|
||||
|
||||
// fire connected callback after constructor has returned
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue