mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +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();
|
||||
conn.terminate();
|
||||
}
|
||||
if (Date.now() - lastHeartbeat > 30000) conn.send('ping');
|
||||
if (Date.now() - lastHeartbeat > 30000) conn.ping();
|
||||
}, 40000);
|
||||
conn.on('pong', () => {
|
||||
lastHeartbeat = Date.now();
|
||||
});
|
||||
conn.onmessage = (e) => {
|
||||
lastHeartbeat = Date.now();
|
||||
if (e.data === 'pong') return;
|
||||
|
||||
Reference in new issue
Block a user