core&ui: websocket: add reversed heartbeat

This commit is contained in:
undefined committed 2023-04-01 22:34:37 +08:00
1 parent 5ce47a0073
commit 84a80fe5b5
2 files changed
+7 -1

No files matched your search

@@ -26,6 +26,10 @@ export default class Sock {
};
this.sock.onmessage = (message) => {
if (message.data === 'pong') return;
if (message.data === 'ping') {
this.sock.send('pong');
return;
}
if (process.env.NODE_ENV !== 'production') console.log('Sock.onmessage: ', message);
const msg = JSON.parse(message.data);
if (msg.error === 'PermissionError' || msg.error === 'PrivilegeError') this.close();