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

30
LINES

< > BotCompany Repo | #1014675 // Counting Test Through WebSocket (shortened, OK)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (2268L/14K).

!7

set flag WebSocketManager_debug.
static long counter;

p {
  webSocketManager = new WebSocketManager;
  doEvery(1000, f count);
}

html {
  ret loadJQuery()
    + "Counting:"
    + hdiv("", id := 'results)
    + hreconnectingWebSockets()
    + hjavascript([[
      var ws = new ReconnectingWebSocket("${URI}");
      ws.onmessage = function(event) {
        var d = event.data;
        $("#results").html(d);
      };
    ]].replace("${URI}", subBot_myWebSocketURI());
}

svoid count {
  ++counter;
  if (empty(webSocketManager.webSockets)) ret;
  print("Sending " + counter + " to " + n2(webSocketManager.webSockets, "socket"));
  webSocketManager.sendToAllWebSockets(str(counter));
}

Author comment

Began life as a copy of #1014671

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1014675
Snippet name: Counting Test Through WebSocket (shortened, OK)
Eternal ID of this version: #1014675/3
Text MD5: 1fee5122a6495b0ff7601f175fe79d5d
Transpilation MD5: 6618d49c2dfa2d23216d011d9999b811
Author: stefan
Category: javax / web
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-29 22:45:52
Source code size: 718 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 360 / 2753
Version history: 2 change(s)
Referenced in: [show references]