!7 static Map wsToState = weakHashMap(); static int interval = 200, initialChars = 65536; static long timeout = 10*60000L; // larger timeout since we have no idle mechanism yet (todo) static File fileToLog() { ret mechVersionsLog(); } p { initWebSockets(); doEvery(interval, f update); } html { ret "Use WebSocket: " + subBot_myWebSocketURI(); } svoid update { if (webSocketManager.isEmpty()) ret; File f = fileToLog(); long len = fileSize(f); for (O ws : webSocketManager.webSockets()) { Long l = wsToState.get(ws); if (l == null) { // new WebSocket set(ws, 'timeout, timeout); wsToState.put(ws, l = max(0, len-initialChars)); // TODO call(ws, 'send, 'clear); } if (len > l) { S newStuff = unquoteAllLines(loadTextFilePart(f, l, len)); wsToState.put(ws, len); call(ws, 'send, "+" + newStuff); } } }