mirror of
https://github.com/wisplite/tether-ts.git
synced 2026-05-01 06:22:41 -05:00
tons of bugfixes and additional logging
This commit is contained in:
Vendored
+10
-3
@@ -23,7 +23,14 @@ export class WebSocketHandler {
|
||||
this.reconnectAttempts = 0;
|
||||
};
|
||||
ws.onmessage = (event) => {
|
||||
const data = JSON.parse(String(event.data));
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(String(event.data));
|
||||
}
|
||||
catch (e) {
|
||||
console.error('Tether: invalid JSON message', event.data, e);
|
||||
return;
|
||||
}
|
||||
if (data.type === 'query') {
|
||||
this.onQuery(data.location, data.data);
|
||||
}
|
||||
@@ -34,8 +41,8 @@ export class WebSocketHandler {
|
||||
console.error(data.error);
|
||||
}
|
||||
};
|
||||
ws.onclose = () => {
|
||||
console.log('Disconnected from Tether');
|
||||
ws.onclose = (event) => {
|
||||
console.log('Disconnected from Tether', 'code:', event.code, 'reason:', event.reason || '(none)', 'wasClean:', event.wasClean);
|
||||
this.attemptReconnect();
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user