mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
add 'drain' emit to WS
This commit is contained in:
@@ -82,9 +82,17 @@ WS.prototype.doOpen = function(){
|
||||
*/
|
||||
|
||||
WS.prototype.write = function(packets){
|
||||
for (var i = 0, l = packets.length; i < l; i++) {
|
||||
this.socket.send(parser.encodePacket(packets[i]));
|
||||
}
|
||||
// encodePayload instead of encodePacket
|
||||
this.writable = false;
|
||||
this.socket.send(parser.encodePayload(packets));
|
||||
// check periodically if we're done sending
|
||||
var bufferedAmountId = this.setInterval(function() {
|
||||
if (socket.bufferedAmount == 0) {
|
||||
clearInterval(bufferedAmountId);
|
||||
this.writable = true;
|
||||
this.emit('drain');
|
||||
}
|
||||
}, 50);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user