!7 static Map wsToState = weakHashMap(); static int nFirstChars = 256, interval = 200; sclass State { S firstChars; int length; *() {} *(StringBuffer log) { init(log); } void init(StringBuffer log) { firstChars = stringBuffer_takeFirst(nFirstChars, log); length = 0; } bool valid(StringBuffer log) { ret eq(firstChars, stringBuffer_takeFirst(nFirstChars, log)); } } static StringBuffer log() { ret (StringBuffer) get(mainBot(), 'local_log); } p { initWebSockets(); doEvery(interval, f update); } html { ret htitle_h3("Eleu Live Log") + subBot_html_webSocketBasedLogView(); } svoid update { StringBuffer log = log(); for (O ws : webSocketManager.webSockets()) { State s = wsToState.get(ws); if (s == null) wsToState.put(ws, s = new State); if (!s.valid(log)) { s.init(log); call(ws, 'send, 'clear); continue; } S newStuff = stringBuffer_substring(log, s.length); if (nempty(newStuff)) { s.length = l(log); call(ws, 'send, "+" + newStuff); } } }