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

30
LINES

< > BotCompany Repo | #1014041 // serveHttpsWithWebsockets

JavaX fragment (include)

1  
static WebSocketHTTPD serveHttpsWithWebsockets_server;
2  
static int serveHttpsWithWebsockets_port = 8443;
3  
4  
static new TreeSet<String> serveHttpsWithWebsockets_peers;
5  
6  
// factory: func(NanoHTTPD.IHTTPSession) -> WebSocket
7  
static int serveHttpsWithWebsockets(int port, File keystore, S pass, O factory) ctex {
8  
  serveHttpsWithWebsockets_port = port;
9  
  serveHttpsWithWebsockets_server = new WebSocketHTTPD(port, factory);
10  
  serveHttpsWithWebsockets_server.makeSecure(serveHttps_makeSSLSocketFactory(keystore, pass));
11  
serveHttpsWithWebsockets_server.start();
12  
  ret serveHttpsWithWebsockets_port();
13  
}
14  
15  
// serve on random port, return port number used
16  
static int serveHttpsWithWebsockets(File keystore, S pass, O factory) {
17  
  serveHttpsWithWebsockets(0, keystore, pass, factory);
18  
  ret serveHttpsWithWebsockets_port();
19  
}
20  
21  
static int serveHttpsWithWebsockets_port() {
22  
  ret serveHttpsWithWebsockets_server == null ? 0 : serveHttpsWithWebsockets_server.getListeningPort();
23  
}
24  
25  
static void cleanMeUp_serveHttpsWithWebsockets() {
26  
  if (serveHttpsWithWebsockets_server != null) {
27  
    serveHttpsWithWebsockets_server.stop();
28  
    serveHttpsWithWebsockets_server = null;
29  
  }
30  
}

Author comment

Began life as a copy of #1009197

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: #1014041
Snippet name: serveHttpsWithWebsockets
Eternal ID of this version: #1014041/3
Text MD5: 03ce2909d40f6241a007d7d6f6b93bc9
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-03-25 15:30:05
Source code size: 1188 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 437 / 477
Version history: 2 change(s)
Referenced in: [show references]