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

47
LINES

< > BotCompany Repo | #1013839 // hSilentComputator (for sub bots) - place in <body>

JavaX fragment (include)

sS hSilentComputator() {
  ret hSilentComputator(hSilentComputator_defaultURI());
}

sS hSilentComputator(S wsUri) {
  ret hSilentComputator(wsUri, "");
}

sS hSilentComputator(S wsUri, S flag) {
  if (nempty(flag)) wsUri = addSlash(wsUri) + flag;
  
  ret div("Calculating", id := 'calcing)
  + hcss([[#calcing {
position: fixed;
width: 100%;
height: 100vh;
z-index: 9999;
visibility: hidden;
}]])
    + hMakeComputerID()
    + hreconnectingWebSockets()
    + hjavascript([[
      function sendPing() {
        ${PINGCMD}
      }
      
      var working = false;
      var benchResultl;
      var ws = new ReconnectingWebSocket("${URI}");
      ws.onopen = function(event) {
        console.log("WebSocket opened.");
      };
      ws.onmessage = function(event) {
        var d = event.data;
        while (d.length > 0 && d.charCodeAt(d.length-1) == 0)
          d = d.substring(0, d.length-1);
        console.log("Evaluating: " + d);
        var geval = eval; // use global scope
        geval(d);
        console.log("Evaluated.");
      };
      
      //working = true; // XXX
      //console.log("Eval test: " + eval('working'));
  ]].replace("${URI}", wsUri)
    .replace("${PINGCMD}", nodes_pingCmd()));
}

Author comment

Began life as a copy of #1013835

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013839
Snippet name: hSilentComputator (for sub bots) - place in <body>
Eternal ID of this version: #1013839/35
Text MD5: 5e1daf07a3ee0529080116e53e0249e3
Author: stefan
Category: javax / web
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-16 16:52:36
Source code size: 1263 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 535 / 577
Version history: 34 change(s)
Referenced in: [show references]