Warning: session_start(): open(/var/lib/php/sessions/sess_cu7q5bh5s7569l8dut801tgj65, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!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(), 'print_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(log));
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);
}
}
}