Download Jar. Libraryless. Click here for Pure Java version (2549L/17K/64K).
!7 set flag ExpiringMap2_debug. static long timeout = 60000; static ExpiringMap2<S, Bool> recenctlyConnectedComputers_internal = new ExpiringMap2(5000, f updateValue); static new MultiSet<S> activeConnections; static Map<S, Bool> recentlyConnectedComputers = synchroMap(recenctlyConnectedComputers_internal); static Var<Int> connected2 = new(0); svoid updateValue { Set<S> set1 = keys(activeConnections); Set<S> set2 = keys(recentlyConnectedComputers); int n = l(mergeSets(set1, set2)); //int n = l(connectedComputers); connected2.set(n); print("Updated value to " + n + " (" + l(set1) + "/" + l(set2) + ")"); } p { // TODO (maybe): add countdown to ExpiringMap instead doEvery(1000, r { synchronized(recentlyConnectedComputers) { recenctlyConnectedComputers_internal.clean(); } }); } html { int count = parseIntOpt(params.get('count)); fS computerID = or2(subBot_getHeader("X-ComputerID"), "unknown"); bool longPoll = params.get('count) != null; if (computerID != null) { activeConnections.add(computerID); print("Have active connections from " + computerID + ": " + activeConnections.get(computerID)); updateValue(); } temp tempAfterwards(r { if (computerID != null) { activeConnections.remove(computerID); print("Disconnected. Have active connections from " + computerID + ": " + activeConnections.get(computerID)); updateValue(); } }); if (computerID != null) print("Got connection from " + computerID); temp tempAfterwards(r { if (computerID != null) { print("Adding recently connected computer: " + computerID); recentlyConnectedComputers.put(computerID, true); } }); if (!longPoll) ret connected2!; print(connected2! + ", eq: " + eq(connected2!, count)); waitForVarToChange_withTimeout(connected2, count, timeout); ret connected2!; }
Began life as a copy of #1014866
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016548 |
Snippet name: | OS Instances Long Poll Bot [LIVE, but we're using the socket version] |
Eternal ID of this version: | #1016548/28 |
Text MD5: | 674eda8b15b5c76457384244a0efb61f |
Transpilation MD5: | 172061d927da53b9aa7ff7535c1dbd59 |
Author: | stefan |
Category: | javax / web |
Type: | JavaX module |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-18 16:51:12 |
Source code size: | 1939 bytes / 61 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 611 / 2494 |
Version history: | 27 change(s) |
Referenced in: | [show references] |