Permalink
Browse files

only add id if there isnt one

  • Loading branch information...
1 parent d04a36a commit 7f23c0d0fa518ac0e14159139bc27e145a316e3b tedsuo committed Dec 18, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 transactor.js
View
@@ -1,22 +1,21 @@
var uuid = require('node-uuid');
-var Transactor = function(o){
+var Transactor = module.exports = function(o){
o = o || {};
if(typeof o.transaction_handler === 'function'){
this.onTransaction(o.transaction_handler);
}
this.sockets = {};
};
-module.exports = Transactor;
-
Transactor.prototype.onTransaction = function(transaction_handler){
this.transaction_handler = transaction_handler;
};
Transactor.prototype.addSocket = function(channel,socket){
var trans = this;
- var socket_id = uuid.v4();
+ var socket_id = socket.id || uuid.v4();
+
// add socket to socket pool
if(!this.sockets[channel]) this.sockets[channel] = {};
this.sockets[channel][socket_id] = socket;

0 comments on commit 7f23c0d

Please sign in to comment.