Warning: session_start(): open(/var/lib/php/sessions/sess_c4cj7k0phvpiub6dpqi6sikp6d, 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
cmodule CatEar > DynPrintLog {
transient long timeout = 60000;
transient int interval = 50; // TODO: use blocking wait
int httpPort = 8082;
S toSay;
LS inputLines = synchroList();
LS outgoingLines = synchroList();
start-thread {
dm_vmBus_onMessage androidCatShouldSay(vf say);
ownResource(serveHttpFromFunction(httpPort, func(S uri, SS params) {
if (!webAuthed(params)) {
if (eq(uri, "/poll"))
sleep(timeout);
ret "not authed";
}
S input = params.get('input);
if (nempty(input)) {
add(inputLines, input);
printWithTime("Got input: " + input);
vmBus_send('androidCatInput, module(), input);
change();
}
if (eq(uri, "/poll"))
ret serveLongPoll(timeout, interval, func {
LS l = getAndClearList(outgoingLines);
if (empty(l)) null;
for (S s : l)
printWithTime("Served output: " + s);
change();
ret lines_rtrim(l);
});
ret "OK";
}));
}
void sayIt() {
if (empty(toSay)) ret;
add(outgoingLines, toSay);
change();
}
visual centerAndSouth(super,
withMargin(dm_textFieldAndSubmit('toSay, 'sayIt)));
// API
void say(S s) enter {
setField(toSay := s);
sayIt();
}
}