!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 (otherwise screen flickers sometimes) static File fileToLog() { ret getProgramFile(#1013927, "versions.log"); } p { initWebSockets(); doEvery(interval, f update); } html { ret htitle_h3("Mech Live Log") + subBot_html_webSocketBasedLogView(); } 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) { set(ws, 'timeout, timeout); wsToState.put(ws, l = max(0, len-initialChars)); call(ws, 'send, 'clear); } if (len > l) { S newStuff = unquoteAllLines(loadTextFilePart(f, l, len)); wsToState.put(ws, len); call(ws, 'send, "+" + newStuff); } } }