Uses 211K of libraries. Click here for Pure Java version (3229L/18K).
1 | !include once #1015699 // websocket |
2 | |
3 | svoid webSocketTest(S url) ctex { |
4 | print("Connecting to " + url); |
5 | WebSocketClient client = new(new URI(url)) { |
6 | public void onMessage(S s) { |
7 | print("Received: " + s); |
8 | } |
9 | |
10 | public void onOpen(ServerHandshake handshake) { |
11 | print("WebSocket opened"); |
12 | } |
13 | |
14 | public void onClose(int code, S reason, bool remote) { print("WebSocket closed"); } |
15 | public void onError(Exception e) { printStackTrace(e); } |
16 | }; |
17 | |
18 | client.connect(); |
19 | afterwards { client.close(); } |
20 | sleepSeconds(60); |
21 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032381 |
Snippet name: | webSocketTest - connects for 60s and prints all received messages to console |
Eternal ID of this version: | #1032381/3 |
Text MD5: | 7b4b1cc50332f3129331f91fdcf391a5 |
Transpilation MD5: | 1481b2b58653f905938f30c560c37fad |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-02 02:47:59 |
Source code size: | 569 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 189 / 224 |
Version history: | 2 change(s) |
Referenced in: | [show references] |