Uses 911K of libraries. Click here for Pure Java version (6526L/36K).
!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<S> 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(); } }
Began life as a copy of #1014866
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023280 |
Snippet name: | Android Controller (port 8082, control the cat on the phone, OLD version for single user) |
Eternal ID of this version: | #1023280/16 |
Text MD5: | 970edf592f0a58d4aeb30a163443eeaf |
Transpilation MD5: | 897564a112e59888e175db2dc5373bc8 |
Author: | stefan |
Category: | javax / web / a.i. / android |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-06-11 19:32:56 |
Source code size: | 1394 bytes / 58 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 331 / 9793 |
Version history: | 15 change(s) |
Referenced in: | [show references] |