Libraryless. Click here for Pure Java version (5374L/40K).
1 | import javax.net.*; |
2 | import javax.net.ssl.*; |
3 | |
4 | static L<WebSocketHTTPD> serveHttpsWithWebsockets_multiplePorts_servers = synchroList(); |
5 | |
6 | // factory: func(NanoHTTPD.IHTTPSession) -> WebSocket |
7 | static void serveHttpsWithWebsockets_multiplePorts(File keystore, S pass, O factory, int... ports) ctex { |
8 | for (int port : ports) { |
9 | WebSocketHTTPD httpd = new WebSocketHTTPD(port, factory); |
10 | httpd.makeSecure(makeSSLServerSocketFactory(keystore, pass)); |
11 | serveHttpsWithWebsockets_multiplePorts_servers.add(httpd); |
12 | httpd.start(); |
13 | } |
14 | } |
15 | |
16 | // factory: func(NanoHTTPD.IHTTPSession) -> WebSocket |
17 | static void serveHttpsWithWebsockets_multiplePorts(SSLServerSocketFactory socketFactory, O factory, int... ports) ctex { |
18 | for (int port : ports) { |
19 | WebSocketHTTPD httpd = new WebSocketHTTPD(port, factory); |
20 | httpd.makeSecure(socketFactory); |
21 | serveHttpsWithWebsockets_multiplePorts_servers.add(httpd); |
22 | httpd.start(); |
23 | } |
24 | } |
25 | |
26 | static void cleanMeUp_serveHttpsWithWebsockets_multiplePorts() { |
27 | for (WebSocketHTTPD httpd : cloneList(serveHttpsWithWebsockets_multiplePorts_servers)) { |
28 | pcall { httpd.stop(); } |
29 | serveHttpsWithWebsockets_multiplePorts_servers.remove(httpd); |
30 | } |
31 | } |
Began life as a copy of #1013354
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018507 |
Snippet name: | serveHttpsWithWebsockets_multiplePorts |
Eternal ID of this version: | #1018507/6 |
Text MD5: | 22bbed0eb3da18d3b1090b257da73a17 |
Transpilation MD5: | e95747ab483578e37e27224aed6d0604 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-02 15:26:56 |
Source code size: | 1214 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 315 / 420 |
Version history: | 5 change(s) |
Referenced in: | [show references] |