Permalink
Browse files

support hook on existing websocket server

  • Loading branch information...
1 parent e1e634f commit 27edb83783dcf88bc8a6c2c58c4b9696889236bd tom zhou committed Jan 16, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/server.js
View
@@ -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);

0 comments on commit 27edb83

Please sign in to comment.