!7 cmodule CatEar > DynPrintLog { transient long timeout = 60000; transient int interval = 50; // TODO: use blocking wait int httpPort = 8082; LS inputLines = synchroList(); LS outgoingLines = synchroList(); start-thread { 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); vmBus_send('androidCatInput, module(), input); change(); } if (eq(uri, "/poll")) ret serveLongPoll(timeout, interval, func { LS l = getAndClearList(outgoingLines); if (empty(l)) null; change(); ret lines_rtrim(l); }); ret "OK"; })); } }