Libraryless. Click here for Pure Java version (5831L/40K).
1 | !7 |
2 | |
3 | static long timeout = 60000; |
4 | static long networkLatency = 10000; |
5 | |
6 | sclass ConnectToServer extends DynBigNumber { |
7 | long count; |
8 | transient bool connected; |
9 | |
10 | void start { |
11 | super.start(); |
12 | thread "Connect" { |
13 | while licensed { |
14 | withMinTime(1000, r { |
15 | try { |
16 | S s = loadPageWithTimeout(butterBotURL(#1016548) + "/" + randomID() /* avoid spam block */ + hquery(+count), timeout+networkLatency); |
17 | if (s == null) setField(connected := false); |
18 | else { |
19 | print("Page: " + s); |
20 | setFields(connected := true, count := parseInt(s)); |
21 | updateValue(); |
22 | } |
23 | } catch e { |
24 | printShortException(e); |
25 | setField(connected := false); |
26 | updateValue(); |
27 | } |
28 | }); |
29 | } |
30 | } |
31 | } |
32 | |
33 | void updateValue { |
34 | setValue(connected ? str(count) : "?"); |
35 | } |
36 | } |
Began life as a copy of #1016455
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: | #1016551 |
Snippet name: | Connect To Server [Long Poll Version, Dyn Module] |
Eternal ID of this version: | #1016551/12 |
Text MD5: | 6977a46d2a09be92d87d2479d6187c2a |
Transpilation MD5: | 2653104c820273fdf3638eacb86c04ff |
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-06-23 19:09:44 |
Source code size: | 930 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 491 / 980 |
Version history: | 11 change(s) |
Referenced in: | [show references] |