mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: websocket: allow any message as heartbeat
This commit is contained in:
1 file changed
+1
-1
@@ -388,9 +388,9 @@ export function Connection(
|
|||||||
if (Date.now() - lastHeartbeat > 40000) conn.close(4000, 'Heartbeat timeout');
|
if (Date.now() - lastHeartbeat > 40000) conn.close(4000, 'Heartbeat timeout');
|
||||||
}, 40000);
|
}, 40000);
|
||||||
conn.onmessage = (e) => {
|
conn.onmessage = (e) => {
|
||||||
|
lastHeartbeat = Date.now();
|
||||||
if (e.data === 'ping') {
|
if (e.data === 'ping') {
|
||||||
conn.send('pong');
|
conn.send('pong');
|
||||||
lastHeartbeat = Date.now();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
h.message?.(JSON.parse(e.data.toString()));
|
h.message?.(JSON.parse(e.data.toString()));
|
||||||
|
|||||||
Reference in new issue
Block a user