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

29
LINES

< > BotCompany Repo | #1009197 // serveHttpWithWebsockets

JavaX fragment (include)

1  
static WebSocketHTTPD serveHttpWithWebsockets_server;
2  
static int serveHttpWithWebsockets_port = 8888;
3  
4  
static new TreeSet<String> serveHttpWithWebsockets_peers;
5  
6  
// factory: func(NanoHTTPD.IHTTPSession) -> WebSocket
7  
static int serveHttpWithWebsockets(int port, O factory) ctex {
8  
  serveHttpWithWebsockets_port = port;
9  
  serveHttpWithWebsockets_server = new WebSocketHTTPD(port, factory);
10  
  serveHttpWithWebsockets_server.start();
11  
  ret serveHttpWithWebsockets_port();
12  
}
13  
14  
// serve on random port, return port number used
15  
static int serveHttpWithWebsockets(O factory) {
16  
  serveHttpWithWebsockets(0, factory);
17  
  ret serveHttpWithWebsockets_port();
18  
}
19  
20  
static int serveHttpWithWebsockets_port() {
21  
  ret serveHttpWithWebsockets_server == null ? 0 : serveHttpWithWebsockets_server.getListeningPort();
22  
}
23  
24  
static void cleanMeUp_serveHttpWithWebsockets() {
25  
  if (serveHttpWithWebsockets_server != null) {
26  
    serveHttpWithWebsockets_server.stop();
27  
    serveHttpWithWebsockets_server = null;
28  
  }
29  
}

Author comment

Began life as a copy of #1001648

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: #1009197
Snippet name: serveHttpWithWebsockets
Eternal ID of this version: #1009197/10
Text MD5: f17c6ae3b487cbf71f11ffddce722333
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-03 02:32:42
Source code size: 1014 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 519 / 559
Version history: 9 change(s)
Referenced in: [show references]