Permalink
Browse files

remove close/error/drain event callback leak

  • Loading branch information...
1 parent 274c4b0 commit 0db32e9d3e009a8cbc3b5be08ed810fbe0d9b30c @ericz ericz committed Jan 16, 2013
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/client.js
View
@@ -34,12 +34,28 @@ function BinaryClient(socket, options) {
this._socket.binaryType = 'arraybuffer';
this._socket.addEventListener('open', function(){
+ // if node
+ self._socket._sender._socket.on('drain', function(){
+ var ids = Object.keys(self.streams);
+ for (var i = 0, ii = ids.length; i < ii; i++) {
+ self.streams[ids[i]]._onDrain();
+ }
+ });
+ // end node
self.emit('open');
});
this._socket.addEventListener('error', function(error){
+ var ids = Object.keys(self.streams);
+ for (var i = 0, ii = ids.length; i < ii; i++) {
+ self.streams[ids[i]]._onError(error);
+ }
self.emit('error', error);
});
this._socket.addEventListener('close', function(code, message){
+ var ids = Object.keys(self.streams);
+ for (var i = 0, ii = ids.length; i < ii; i++) {
+ self.streams[ids[i]]._onClose();
+ }
self.emit('close', code, message);
});
this._socket.addEventListener('message', function(data, flags){
@@ -234,5 +250,4 @@ BinaryClient.prototype.close = BinaryClient.prototype.destroy = function(code, m
this._socket.close(code, message);
};
-
exports.BinaryClient = BinaryClient;

0 comments on commit 0db32e9

Please sign in to comment.