Skip to content

Commit

Permalink
support hook on existing websocket server
Browse files Browse the repository at this point in the history
  • Loading branch information
tom zhou committed Jan 16, 2013
1 parent e1e634f commit 27edb83
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/server.js
Expand Up @@ -17,7 +17,11 @@ function BinaryServer(options) {
this.clients = {};
this._clientCounter = 0;

this._server = new ws.Server(options);
if (options.server && (options.server instanceof ws.Server))
this._server = options.server;
else
this._server = new ws.Server(options);

this._server.on('connection', function(socket){
var clientId = self._clientCounter;
var binaryClient = new BinaryClient(socket, options);
Expand Down

0 comments on commit 27edb83

Please sign in to comment.