Heartbeat de présence configurable dans la salle de conférence

This commit is contained in:
2020-10-13 09:38:09 +02:00
parent 0b93b0875e
commit 50ec72fcf4
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import React, { FunctionComponent, useEffect } from 'react';
import { Config } from '../../config';
import { useUserProfile } from '../../gql/queries/profile';
import { useConference } from '../../hooks/useConference';
import { Page } from '../Page';
@ -13,8 +14,6 @@ const StatusThumbsUp = 'thumbs-up';
const StatusThumbsDown = 'thumbs-down';
const StatusNoVote = 'no-vote';
const HeartbeatInterval = 5000;
export const ConferencePage:FunctionComponent<ConferencePageProps> = () => {
const { user } = useUserProfile();
const { uuid, data, setNickname, setEmail, ping, setStatus, forget } = useConference();
@ -29,7 +28,7 @@ export const ConferencePage:FunctionComponent<ConferencePageProps> = () => {
useEffect(() => {
ping();
const intervalId = setInterval(() => ping(), HeartbeatInterval);
const intervalId = setInterval(() => ping(), Config.conferenceHeartbeatInterval + (Math.random() * Config.conferenceHeartbeatInterval/2));
return () => clearInterval(intervalId);
}, []);
@ -89,7 +88,7 @@ export const ConferencePage:FunctionComponent<ConferencePageProps> = () => {
if (p === uuid) return null;
if (now.getTime() > lastHeartBeat.getTime() + HeartbeatInterval) {
if (now.getTime() > lastHeartBeat.getTime() + Config.conferenceHeartbeatInterval*2) {
forget(p);
return null;
}