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

29
LINES

< > BotCompany Repo | #1009197 // serveHttpWithWebsockets

JavaX fragment (include)

static WebSocketHTTPD serveHttpWithWebsockets_server;
static int serveHttpWithWebsockets_port = 8888;

static new TreeSet<String> serveHttpWithWebsockets_peers;

// factory: func(NanoHTTPD.IHTTPSession) -> WebSocket
static int serveHttpWithWebsockets(int port, O factory) ctex {
  serveHttpWithWebsockets_port = port;
  serveHttpWithWebsockets_server = new WebSocketHTTPD(port, factory);
  serveHttpWithWebsockets_server.start();
  ret serveHttpWithWebsockets_port();
}

// serve on random port, return port number used
static int serveHttpWithWebsockets(O factory) {
  serveHttpWithWebsockets(0, factory);
  ret serveHttpWithWebsockets_port();
}

static int serveHttpWithWebsockets_port() {
  ret serveHttpWithWebsockets_server == null ? 0 : serveHttpWithWebsockets_server.getListeningPort();
}

static void cleanMeUp_serveHttpWithWebsockets() {
  if (serveHttpWithWebsockets_server != null) {
    serveHttpWithWebsockets_server.stop();
    serveHttpWithWebsockets_server = null;
  }
}

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: 518 / 558
Version history: 9 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1009554 - serveHttpWithWebSockets - synonym of serveHttpWithWebsockets
#1014041 - serveHttpsWithWebsockets