mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-20 18:29:57 -04:00
Change microbit extension to send BLE socket error on data lost, instead of calling disconnect directly.
This commit is contained in:
parent
fab292889f
commit
fdda1e53e3
5 changed files with 21 additions and 6 deletions
src/io
|
@ -73,7 +73,10 @@ class BLE extends JSONRPCWebSocket {
|
|||
* Close the websocket.
|
||||
*/
|
||||
disconnect () {
|
||||
if (!this._connected) return;
|
||||
|
||||
this._ws.close();
|
||||
this._connected = false;
|
||||
if (this._discoverTimeoutID) {
|
||||
window.clearTimeout(this._discoverTimeoutID);
|
||||
}
|
||||
|
@ -191,9 +194,10 @@ class BLE extends JSONRPCWebSocket {
|
|||
|
||||
if (!this._connected) return;
|
||||
|
||||
this._connected = false;
|
||||
if (this._disconnectCallback) {
|
||||
this._disconnectCallback();
|
||||
this._disconnectCallback(); // will trigger a disconnect()
|
||||
} else {
|
||||
this.disconnect();
|
||||
}
|
||||
|
||||
this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT_ERROR, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue