mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: websocket: use ping frame rather than ping message (#717)
This commit is contained in:
1 parent
ac24564212
commit
bdbce10ecd
1 file changed
+4
-1
@@ -438,8 +438,11 @@ export function Connection(
|
|||||||
clean();
|
clean();
|
||||||
conn.terminate();
|
conn.terminate();
|
||||||
}
|
}
|
||||||
if (Date.now() - lastHeartbeat > 30000) conn.send('ping');
|
if (Date.now() - lastHeartbeat > 30000) conn.ping();
|
||||||
}, 40000);
|
}, 40000);
|
||||||
|
conn.on('pong', () => {
|
||||||
|
lastHeartbeat = Date.now();
|
||||||
|
});
|
||||||
conn.onmessage = (e) => {
|
conn.onmessage = (e) => {
|
||||||
lastHeartbeat = Date.now();
|
lastHeartbeat = Date.now();
|
||||||
if (e.data === 'pong') return;
|
if (e.data === 'pong') return;
|
||||||
|
|||||||
Reference in new issue
Block a user