Skip to content

Commit

Permalink
Specify liveReloadAttempts
Browse files Browse the repository at this point in the history
This uses the new retry capability added in
stealjs/live-reload#18

Sets liveReloadAttempts to 3, so there will be 2 retries after the
connection fails to establish.

Fixes #62
  • Loading branch information
matthewp committed Sep 28, 2015
1 parent 2479eb1 commit c3fecf5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
1 change: 1 addition & 0 deletions lib/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = function (options) {

var system = {
liveReload: options.liveReload,
liveReloadAttempts: 3,
liveReloadHost: os.hostname()
};
if(options.main) {
Expand Down
32 changes: 1 addition & 31 deletions lib/server/websocket.js
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
var WebSocketClient = require('websocket').client;

var MyWebSocket = global.WebSocket = function(address){
this.address = address;

// Create the connection here
this.client = new WebSocketClient();

var ws = this;
this.client.on('connect', function(connection){
ws.connection = connection;

ws.connection.on("message", function(data){
var msg = data.utf8Data;
if(ws.onmessage) {
ws.onmessage({
data: msg
});
}
});

if(ws.onopen) {
ws.onopen();
}
});
this.client.connect(this.address);
};

MyWebSocket.prototype.send = function(msg){
this.connection.send(msg);
};
global.WebSocket = require("websocket").w3cwebsocket;

0 comments on commit c3fecf5

Please sign in to comment.