You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
377 B
28 lines
377 B
const URL = '/api/ping'; |
|
const INTERVAL = 4000; |
|
|
|
function ping() { |
|
try { |
|
fetch(URL); |
|
} catch (e) { |
|
console.error(e); |
|
} |
|
} |
|
|
|
class ViewerPing { |
|
timer: ReturnType<typeof setInterval>; |
|
|
|
start() { |
|
this.stop(); |
|
|
|
this.timer = setInterval(() => { |
|
ping(); |
|
}, INTERVAL); |
|
} |
|
|
|
stop() { |
|
clearInterval(this.timer); |
|
} |
|
} |
|
|
|
export default ViewerPing;
|
|
|