Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #130 from roamm/packet_send_callback

Fixed packet send callback issues
  • Loading branch information...
commit 3c968fcb55d9cdfab4db3665ff089b9b64a1fddc 2 parents 9d9fe9e + 0dfa68c
@rauchg rauchg authored
View
15 lib/socket.js
@@ -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);
View
8 lib/transports/flashsocket.js
@@ -37,6 +37,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.
*
View
8 lib/transports/websocket.js
@@ -56,6 +56,14 @@ WebSocket.prototype.name = 'websocket';
WebSocket.prototype.handlesUpgrades = true;
/**
+ * Advertise framing support.
+ *
+ * @api public
+ */
+
+WebSocket.prototype.supportsFraming = true;
+
+/**
* Processes the incoming data.
*
* @param {String} encoded packet
Please sign in to comment.
Something went wrong with that request. Please try again.