Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit 00fbe67

Browse files
author
bhasher
committed
Ping-pong client-side
1 parent e0ae2e0 commit 00fbe67

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/publics/js/dev/utils/websocket/socket.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ export default class Socket{
4040
}
4141
}, 1000);
4242

43+
/**
44+
* Ping-pong alive event
45+
*/
46+
document.addEventListener('socket.receive.ping', e => {
47+
this.send(JSON.stringify({
48+
event: 'pong',
49+
time: Date.now(),
50+
}))
51+
})
52+
4353

4454
}
4555

0 commit comments

Comments
 (0)