From 27612096311ac8077380726ae8d1679f7ed8587e Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Wed, 16 Jan 2019 16:00:25 -0500 Subject: [PATCH] Changing JSDoc slightly, again. --- src/io/ble.js | 9 ++++----- src/io/bt.js | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/io/ble.js b/src/io/ble.js index e8902d6f6..920fea153 100644 --- a/src/io/ble.js +++ b/src/io/ble.js @@ -192,20 +192,19 @@ class BLE extends JSONRPCWebSocket { * - going out of bluetooth range * - being powered down * - * If the extension using this BLE socket has a disconnect callback, call it, - * and also disconnect the socket. Finally, emit an error to the runtime. + * Disconnect the socket, and if the extension using this socket has a + * disconnect callback, call it. Finally, emit an error to the runtime. */ handleDisconnectError (/* e */) { // log.error(`BLE error: ${JSON.stringify(e)}`); if (!this._connected) return; + this.disconnect(); + if (this._disconnectCallback) { this._disconnectCallback(); } - - this.disconnect(); - this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT_ERROR, { message: `Scratch lost connection to`, extensionId: this._extensionId diff --git a/src/io/bt.js b/src/io/bt.js index 8eac43939..af7b39542 100644 --- a/src/io/bt.js +++ b/src/io/bt.js @@ -135,20 +135,20 @@ class BT extends JSONRPCWebSocket { * - going out of bluetooth range * - being powered down * - * If the extension using this BLE socket has a disconnect callback, call it, - * and also disconnect the socket. Finally, emit an error to the runtime. + * Disconnect the socket, and if the extension using this socket has a + * disconnect callback, call it. Finally, emit an error to the runtime. */ handleDisconnectError (/* e */) { // log.error(`BT error: ${JSON.stringify(e)}`); if (!this._connected) return; + this.disconnect(); + if (this._disconnectCallback) { this._disconnectCallback(); } - this.disconnect(); - this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECT_ERROR, { message: `Scratch lost connection to`, extensionId: this._extensionId