MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / startPolling

Function startPolling

frontend/src/store/modules/process.ts:240–279  ·  view source on GitHub ↗
(type: 'ps' | 'net', interval = 3000, initialDelay = 0)

Source from the content-addressed store, hash-verified

238 };
239
240 const startPolling = (type: 'ps' | 'net', interval = 3000, initialDelay = 0) => {
241 stopPolling();
242 activePollingType.value = type;
243
244 const sendInitial = () => {
245 if (type === 'ps') {
246 sendPsMessage();
247 } else {
248 sendNetMessage();
249 }
250 };
251
252 const scheduleInitialFetch = () => {
253 if (initialDelay > 0) {
254 setTimeout(sendInitial, initialDelay);
255 } else {
256 sendInitial();
257 }
258 };
259
260 if (isWsOpen()) {
261 scheduleInitialFetch();
262 } else {
263 const checkConnection = setInterval(() => {
264 if (isWsOpen()) {
265 clearInterval(checkConnection);
266 scheduleInitialFetch();
267 }
268 }, 100);
269 setTimeout(() => clearInterval(checkConnection), 5000);
270 }
271
272 pollingTimer = setInterval(() => {
273 if (type === 'ps') {
274 sendPsMessage();
275 } else {
276 sendNetMessage();
277 }
278 }, interval);
279 };
280
281 const stopPolling = () => {
282 if (pollingTimer) {

Callers

nothing calls this directly

Calls 5

stopPollingFunction · 0.85
isWsOpenFunction · 0.85
scheduleInitialFetchFunction · 0.85
sendPsMessageFunction · 0.85
sendNetMessageFunction · 0.85

Tested by

no test coverage detected