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

20
LINES

< > BotCompany Repo | #1036022 // PrintingWebSocketClient

JavaX fragment (include) [tags: use-pretranspiled]

Uses 211K of libraries. Click here for Pure Java version (9212L/51K).

1  
!include once #1015699 // websocket
2  
3  
sclass PrintingWebSocketClient extends WebSocketClient {
4  
  *(URI uri) { super(uri); }
5  
  *(URI uri, SS httpHeaders) { super(uri, httpHeaders); }
6  
  
7  
  public void onMessage(S s) {
8  
    print("WebSocket received: " + s);
9  
  }
10  
11  
  public void onOpen(ServerHandshake handshake) {
12  
    print("WebSocket opened");
13  
  }
14  
  
15  
  public void onClose(int code, S reason, bool remote) {
16  
    print("WebSocket closed, code " + code + ", reason: " + reason + ", remote: " + remote);
17  
  }
18  
  
19  
  public void onError(Exception e) { printStackTrace(e); }
20  
}

Author comment

Began life as a copy of #1032381

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036022
Snippet name: PrintingWebSocketClient
Eternal ID of this version: #1036022/2
Text MD5: 1d14dbbedf10356b33da09cd0d43f12a
Transpilation MD5: 19fbf8e2f16c54909666a87b4c1d8db5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-01 12:58:26
Source code size: 583 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 154 / 202
Version history: 1 change(s)
Referenced in: [show references]