Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

377 B
Raw Blame
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;