Libraryless. Click here for Pure Java version (8187L/55K).
1 | !7 |
2 | |
3 | sclass AllOnlineComputers extends DynCalculatedList { |
4 | LS computerIDs, data; |
5 | transient DialogIO io; |
6 | |
7 | L<S> calc() { ret data; } |
8 | |
9 | void cleanMeUp { |
10 | if (io != null) io.close(); |
11 | } |
12 | |
13 | start { |
14 | connect(); |
15 | doEvery(30000, r { if (io != null) io.sendLine("") }); |
16 | } |
17 | |
18 | void connect { |
19 | thread "Connect" { |
20 | while licensed { |
21 | try { |
22 | io = talkTo("smartbot.botcompany.de", 6000); |
23 | io.getSocket().setSoTimeout(30000+10000); |
24 | print("Connected."); |
25 | temp tempAfterwards(r { print("Disconnected.") }); |
26 | io.sendLine(format("computerID=*", computerID())); |
27 | io.sendLine(format("sub *", "computerIDs")); |
28 | print("Sent computer ID: " + computerID()); |
29 | S line; |
30 | while ((line = io.readLine()) != null) { |
31 | if (nempty(line)) print("Have msg: " + line); |
32 | new Matches m; |
33 | if (swic(line, "ComputerIDs = ", m)) { |
34 | computerIDs = safeUnstruct($1); |
35 | fO computerNames = dm_computerNames_opt(); |
36 | setField(data := sortedIC(map(computerIDs, func(S id) -> S { |
37 | S name = dm_callOpt(computerNames, 'nameForID, id); |
38 | ret (eq(id, computerID()) ? "[this one] " : "") |
39 | + (nempty(name) ? name + " (" + id + ")" : id); |
40 | }))); |
41 | vmBus_send('onlineComputerIDs, computerIDs); |
42 | setModuleName(n2(computerIDs, "Online Computer")); |
43 | } |
44 | } |
45 | } catch e { // pcall would also do an annoying message box |
46 | printShortException(e); |
47 | } |
48 | io = null; |
49 | sleepSeconds(5); |
50 | } |
51 | } |
52 | } |
53 | |
54 | // API |
55 | |
56 | LS onlineComputerIDs() { ret computerIDs; } |
57 | } |
Began life as a copy of #1016578
download show line numbers debug dex old transpilations
Travelled to 10 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019753 |
Snippet name: | All Online Computers [Show Connected Computers, old version] |
Eternal ID of this version: | #1019753/1 |
Text MD5: | 7d060cd54c35f7c037e2dda6426d2134 |
Transpilation MD5: | a2df493aec78a241f7d5526ef69e8679 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-24 18:19:57 |
Source code size: | 1778 bytes / 57 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 346 / 494 |
Referenced in: | [show references] |