mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Revert "Revert "Fixed packet send callback design issue""
This reverts commit ead08d6e5b.
This commit is contained in:
@@ -247,6 +247,13 @@ Socket.prototype.setupSendCallback = function () {
|
||||
if ('function' == typeof seqFn) {
|
||||
debug('executing send callback');
|
||||
seqFn(self.transport);
|
||||
} else if (Array.isArray(seqFn)) {
|
||||
debug('executing batch send callback');
|
||||
for (var i in seqFn) {
|
||||
if ('function' == typeof seqFn) {
|
||||
seqFn[i](self.transport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -288,9 +295,8 @@ Socket.prototype.sendPacket = function (type, data, callback) {
|
||||
this.writeBuffer.push(packet);
|
||||
|
||||
//add send callback to object
|
||||
if (callback) {
|
||||
this.packetsFn.push(callback);
|
||||
}
|
||||
this.packetsFn.push(callback);
|
||||
|
||||
this.flush();
|
||||
}
|
||||
};
|
||||
@@ -309,6 +315,9 @@ Socket.prototype.flush = function () {
|
||||
this.server.emit('flush', this, this.writeBuffer);
|
||||
var wbuf = this.writeBuffer;
|
||||
this.writeBuffer = [];
|
||||
if (!this.transport.supportsFraming) {
|
||||
this.packetsFn = [this.packetsFn];
|
||||
}
|
||||
this.transport.send(wbuf);
|
||||
this.emit('drain');
|
||||
this.server.emit('drain', this);
|
||||
|
||||
@@ -36,6 +36,14 @@ FlashSocket.prototype.__proto__ = WebSocket.prototype;
|
||||
|
||||
FlashSocket.prototype.name = 'flashsocket';
|
||||
|
||||
/**
|
||||
* Advertise framing support.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
FlashSocket.prototype.supportsFraming = true;
|
||||
|
||||
/**
|
||||
* Listens for new configuration changes of the Manager
|
||||
* this way we can enable and disable the flash server.
|
||||
|
||||
@@ -55,6 +55,14 @@ WebSocket.prototype.name = 'websocket';
|
||||
|
||||
WebSocket.prototype.handlesUpgrades = true;
|
||||
|
||||
/**
|
||||
* Advertise framing support.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
WebSocket.prototype.supportsFraming = true;
|
||||
|
||||
/**
|
||||
* Processes the incoming data.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user