server connections handling

This commit is contained in:
Jan Prochazka
2020-05-01 11:41:18 +02:00
parent 44c19ad277
commit ca7eea8a05
11 changed files with 284 additions and 71 deletions

View File

@@ -0,0 +1,14 @@
import React from 'react';
import { useOpenedConnections } from './globalState';
import axios from './axios';
export default function OpenedConnectionsPinger({ children }) {
const openedConnections = useOpenedConnections();
React.useEffect(() => {
const handle = window.setInterval(() => {
axios.post('server-connections/ping', { connections: openedConnections });
}, 30 * 1000);
return () => window.clearInterval(handle);
}, [openedConnections]);
return children;
}