Missing file
This commit is contained in:
parent
97762c17b0
commit
d6e0b55337
28
web/components/video/viewer-ping.ts
Normal file
28
web/components/video/viewer-ping.ts
Normal file
@ -0,0 +1,28 @@
|
||||
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;
|
Loading…
Reference in New Issue
Block a user