Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1016551 // Connect To Server [Long Poll Version, Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (5831L/40K).

!7

static long timeout = 60000;
static long networkLatency = 10000;

sclass ConnectToServer extends DynBigNumber {
  long count;
  transient bool connected;
  
  void start {
    super.start();
    thread "Connect" {
      while licensed {
        withMinTime(1000, r {
          try {
            S s = loadPageWithTimeout(butterBotURL(#1016548) + "/" + randomID() /* avoid spam block */ + hquery(+count), timeout+networkLatency);
            if (s == null) setField(connected := false);
            else {
              print("Page: " + s);
              setFields(connected := true, count := parseInt(s));
              updateValue();
            }
          } catch e {
            printShortException(e);
            setField(connected := false);
            updateValue();
          }
        });
      }
    }
  }
  
  void updateValue {
    setValue(connected ? str(count) : "?");
  }
}

Author comment

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: 407 / 869
Version history: 11 change(s)
Referenced in: [show references]