mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core&ui: websocket: add reversed heartbeat
This commit is contained in:
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();
|
||||
|
||||
Reference in new issue
Block a user