Skip to content

Commit

Permalink
Add port and hostname options instead of trying to autodetect them.
Browse files Browse the repository at this point in the history
  • Loading branch information
Macil committed Sep 26, 2015
1 parent 4a3b8ad commit 56900ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -72,6 +72,13 @@ Browserify bundle is accessible at. In "websocket" mode, this defaults to
"http://localhost:3123". This is required for the "ajax" mode. This is not
required for "fs" mode.

`p, port` is a number that sets the port to listen on if "websocket" mode is
used. If you change this, you'll most likely want to change the `url` setting
too. Defaults to 3123.

`h, hostname` is the hostname to listen on if "websocket" mode is used. This
defaults to "localhost".

`b, cacheBust` is a boolean which controls whether cache busting should be used
for AJAX requests. This only has an effect if the update mode is set to "ajax".
If true, then a random parameter is appended to the URL on every request. This
Expand Down
8 changes: 2 additions & 6 deletions index.js
Expand Up @@ -61,6 +61,8 @@ module.exports = function(bundle, opts) {
updateMode = 'ajax';
}
var updateUrl = readOpt(opts, 'url', 'u', null);
var port = readOpt(opts, 'port', 'p', 3123);
var hostname = readOpt(opts, 'hostname', 'h', 'localhost');
var updateCacheBust = boolOpt(readOpt(opts, 'cacheBust', 'b', false));
var bundleKey = readOpt(opts, 'key', 'k', updateMode+':'+updateUrl);
var cert = readOpt(opts, 'tlscert', 'C', null);
Expand All @@ -73,12 +75,6 @@ module.exports = function(bundle, opts) {
var sioPath = null;
if (updateMode === 'websocket') {
if (!updateUrl) updateUrl = 'http://localhost:3123';

var m = /:\/\/([^\/:]+)(?::(\d+))?/.exec(updateUrl);
if (!m) throw new Error("Failed to parse update url");
var hostname = m[1];
var port = m[2] ? +m[2] : 80;

sioPath = './'+path.relative(basedir, require.resolve('socket.io-client'));
}

Expand Down

0 comments on commit 56900ab

Please sign in to comment.