From e58c377ff08ccdd067c1aff7454b94f315722079 Mon Sep 17 00:00:00 2001 From: Moritz Peters Date: Thu, 18 Dec 2014 14:35:06 +0100 Subject: [PATCH 1/2] Add option to pass socketio instead of relying solely on the preset global. --- client/garageserver.io.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/garageserver.io.js b/client/garageserver.io.js index 73e0997..d90c13b 100644 --- a/client/garageserver.io.js +++ b/client/garageserver.io.js @@ -27,10 +27,6 @@ var GarageServerIO = (function (socketio) { "use strict"; - if (!socketio) { - throw new Error("GarageServer.IO: Socket.IO not found. Please ensure socket.io.js is referenced before the garageserver.io.js file."); - } - function StateController() { this.clientTime = 0; this.renderTime = 0; @@ -181,6 +177,12 @@ var GarageServerIO = (function (socketio) { initializeGarageServer = function (path, options) { _options = options; + if (options.socketio) { + _io = options.socketio; + } + if (!_io) { + throw new Error("GarageServer.IO: Socket.IO not found. Please ensure socket.io.js is referenced before the garageserver.io.js file."); + } _socket = _io.connect(path + '/garageserver.io'); registerSocketEvents(); }, From d748501614a97b817a984da721beef3aa74f9808 Mon Sep 17 00:00:00 2001 From: Moritz Peters Date: Mon, 28 Sep 2015 11:31:19 +0200 Subject: [PATCH 2/2] Add module.exports to client so that the client code can be used in commonjs environment --- client/garageserver.io.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/garageserver.io.js b/client/garageserver.io.js index d1ae51c..d6bffe3 100644 --- a/client/garageserver.io.js +++ b/client/garageserver.io.js @@ -494,3 +494,7 @@ var GarageServerIO = (function (socketio) { }; }) (window.io); + +if (module) { + module.exports = GarageServerIO; +}