Fixing disconnect to handle different cases differently.
This commit is contained in:
1 parent
151789cbad
commit
65b05a9da4
2 files changed
+16
-6
No files matched your search
+8
-3
@@ -73,14 +73,19 @@ class BLE extends JSONRPCWebSocket {
|
||||
* Close the websocket.
|
||||
*/
|
||||
disconnect () {
|
||||
if (this._ws.readyState !== this._ws.OPEN) return;
|
||||
if (this._ws.readyState === this._ws.OPEN) {
|
||||
this._ws.close();
|
||||
}
|
||||
|
||||
this._ws.close();
|
||||
this._connected = false;
|
||||
if (this._connected) {
|
||||
this._connected = false;
|
||||
}
|
||||
|
||||
if (this._discoverTimeoutID) {
|
||||
window.clearTimeout(this._discoverTimeoutID);
|
||||
}
|
||||
|
||||
// Sets connection status icon to orange
|
||||
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECTED);
|
||||
}
|
||||
|
||||
|
||||
+8
-3
@@ -75,14 +75,19 @@ class BT extends JSONRPCWebSocket {
|
||||
* Close the websocket.
|
||||
*/
|
||||
disconnect () {
|
||||
if (this._ws.readyState !== this._ws.OPEN) return;
|
||||
if (this._ws.readyState === this._ws.OPEN) {
|
||||
this._ws.close();
|
||||
}
|
||||
|
||||
if (this._connected) {
|
||||
this._connected = false;
|
||||
}
|
||||
|
||||
this._ws.close();
|
||||
this._connected = false;
|
||||
if (this._discoverTimeoutID) {
|
||||
window.clearTimeout(this._discoverTimeoutID);
|
||||
}
|
||||
|
||||
// Sets connection status icon to orange
|
||||
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECTED);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user