Skip to content

Commit

Permalink
host:port argument for server
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Gottfried committed Feb 18, 2020
1 parent 9eccffa commit 80b665a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ let server = http.createServer(
const wss = new WebSocket.Server({ noServer: true });


let server_port = process.argv[2];
let [server_host, server_port] = process.argv[2].split(':', 2);
if (server_port === undefined && !isNaN(server_host)) {
server_port = server_host;
server_host = '0.0.0.0';
}

if (! server_port) server_port=8000;
if (!server_port) server_port=8000;
/*
* @authenticator ... function (request, callback) which calls callback(err, client).
* `err` is empty on success and client which should be an object with `key` property.
Expand Down Expand Up @@ -66,5 +70,5 @@ server.on("listening", function onListening() {
`);

});
server.listen(server_port);
server.listen(server_port, server_host);

0 comments on commit 80b665a

Please sign in to comment.