mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 10:06:00 +00:00
server connections handling
This commit is contained in:
14
packages/web/src/utility/OpnedConnectionsPinger.js
Normal file
14
packages/web/src/utility/OpnedConnectionsPinger.js
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user