Download Jar. Libraryless. Click here for Pure Java version (2268L/14K).
1 | !7 |
2 | |
3 | set flag WebSocketManager_debug. |
4 | static long counter; |
5 | |
6 | p { |
7 | webSocketManager = new WebSocketManager; |
8 | doEvery(1000, f count); |
9 | } |
10 | |
11 | html { |
12 | ret loadJQuery() |
13 | + "Counting:" |
14 | + hdiv("", id := 'results) |
15 | + hreconnectingWebSockets() |
16 | + hjavascript([[ |
17 | var ws = new ReconnectingWebSocket("${URI}"); |
18 | ws.onmessage = function(event) { |
19 | var d = event.data; |
20 | $("#results").html(d); |
21 | }; |
22 | ]].replace("${URI}", subBot_myWebSocketURI()); |
23 | } |
24 | |
25 | svoid count { |
26 | ++counter; |
27 | if (empty(webSocketManager.webSockets)) ret; |
28 | print("Sending " + counter + " to " + n2(webSocketManager.webSockets, "socket")); |
29 | webSocketManager.sendToAllWebSockets(str(counter)); |
30 | } |
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: | 493 / 3136 |
Version history: | 2 change(s) |
Referenced in: | [show references] |