Download Jar. Libraryless. Click here for Pure Java version (2739L/18K).
1 | !7 |
2 | |
3 | static Map<O, Long> wsToState = weakHashMap(); |
4 | static int interval = 200, initialChars = 65536; |
5 | static long timeout = 10*60000L; // larger timeout since we have no idle mechanism yet (otherwise screen flickers sometimes) |
6 | |
7 | static File fileToLog() { ret getProgramFile(#1013927, "versions.log"); } |
8 | |
9 | p { |
10 | initWebSockets(); |
11 | doEvery(interval, f update); |
12 | } |
13 | |
14 | html { ret htitle_h3("Mech Live Log") + subBot_html_webSocketBasedLogView(); } |
15 | |
16 | svoid update { |
17 | if (webSocketManager.isEmpty()) ret; |
18 | File f = fileToLog(); |
19 | long len = fileSize(f); |
20 | |
21 | for (O ws : webSocketManager.webSockets()) { |
22 | Long l = wsToState.get(ws); |
23 | if (l == null) { |
24 | set(ws, 'timeout, timeout); |
25 | wsToState.put(ws, l = max(0, len-initialChars)); |
26 | call(ws, 'send, 'clear); |
27 | } |
28 | if (len > l) { |
29 | S newStuff = unquoteAllLines(loadTextFilePart(f, l, len)); |
30 | wsToState.put(ws, len); |
31 | call(ws, 'send, "+" + newStuff); |
32 | } |
33 | } |
34 | } |
Began life as a copy of #1014677
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1014682 |
Snippet name: | Mech Changes Live Log (OK) |
Eternal ID of this version: | #1014682/19 |
Text MD5: | a71b20501b2aee6e56dea26d85d34137 |
Transpilation MD5: | af97534c46d8123ab51cc5648ac9a47e |
Author: | stefan |
Category: | javax / a.i. / web |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-04-30 02:16:49 |
Source code size: | 969 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 530 / 3171 |
Version history: | 18 change(s) |
Referenced in: | [show references] |