mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2024-11-30 18:24:27 +01:00
20 lines
395 B
JavaScript
20 lines
395 B
JavaScript
const ws = new WebSocket('wss://websocket-echo.com/')
|
|
|
|
let timeout = null
|
|
function heartbeat() {
|
|
clearTimeout(timeout)
|
|
|
|
timeout = setTimeout(() => {
|
|
ws.close()
|
|
}, 30000 + 1000)
|
|
}
|
|
|
|
ws.addEventListener('error', console.error)
|
|
ws.addEventListener('open', heartbeat)
|
|
ws.addEventListener('ping', heartbeat)
|
|
ws.addEventListener('close', () => {
|
|
clearTimeout(timeout)
|
|
})
|
|
|
|
export default ws
|