Skip to content

Commit

Permalink
websocket: do error handling for each ws write
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Aug 1, 2012
1 parent 25b48dd commit a80c76f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/transports/websocket.js
Expand Up @@ -70,7 +70,13 @@ WebSocket.prototype.send = function (packets) {
for (var i = 0, l = packets.length; i < l; i++) {
var data = parser.encodePacket(packets[i]);
debug('writing', data);
this.socket.send(data);
this.writable = false;
var self = this;
this.socket.send(data, function (err){
if (err) return self.onError('write error', err.stack);
self.writable = true;
self.emit('drain');
});
}
};

Expand Down

0 comments on commit a80c76f

Please sign in to comment.