mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-12 22:42:03 -04:00
Adding error reporting to runtime from BLESession.
This commit is contained in:
parent
73cc149783
commit
9d66c54f8a
3 changed files with 14 additions and 5 deletions
src/io
|
@ -17,7 +17,7 @@ class BLESession extends JSONRPCWebSocket {
|
|||
|
||||
this._socketPromise = new Promise((resolve, reject) => {
|
||||
this._ws.onopen = resolve;
|
||||
this._ws.onerror = this._sendError(); // TODO: socket error?
|
||||
this._ws.onerror = this._sendError; // TODO: socket error?
|
||||
// TODO: generally handle socket disconnects as errors
|
||||
});
|
||||
|
||||
|
@ -27,6 +27,7 @@ class BLESession extends JSONRPCWebSocket {
|
|||
this._deviceOptions = deviceOptions;
|
||||
this._runtime = runtime;
|
||||
this._ws = ws;
|
||||
this._ws.onclose = this._sendError();
|
||||
|
||||
this._runtime.registerExtensionDevice(extensionId, this);
|
||||
}
|
||||
|
@ -126,14 +127,11 @@ class BLESession extends JSONRPCWebSocket {
|
|||
params.encoding = encoding;
|
||||
}
|
||||
return this.sendRemoteRequest('write', params);
|
||||
// TODO: .then() to clear a busy flag cuz it returned
|
||||
// TODO: send error to runtime to stop yielding
|
||||
}
|
||||
|
||||
_sendError (e) {
|
||||
console.log(`BLESession error ${e}`);
|
||||
// are there different error types?
|
||||
// this._runtime.emit(???????????????)
|
||||
this._runtime.emit(this._runtime.constructor.PERIPHERAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue