Permalink
Browse files

added support for volatile packets

  • Loading branch information...
1 parent adffabe commit 81e8a0c3a5ace051e43bd4905343cf2a9ef1baac @rauchg rauchg committed Mar 7, 2014
Showing with 7 additions and 3 deletions.
  1. +5 −2 lib/client.js
  2. +2 −1 lib/socket.js
View
@@ -126,14 +126,17 @@ Client.prototype.close = function(){
* Writes a packet to the transport.
*
* @param {Object} packet object
+ * @param {Boolean} whether packet is already encoded
+ * @param {Boolean} whether packet is volatile
* @api private
*/
-Client.prototype.packet = function(packet, preEncoded){
+Client.prototype.packet = function(packet, preEncoded, volatile){
var self = this;
// this writes to the actual connection
function writeToEngine(encodedPackets) {
+ if (volatile && !self.conn.transport.writable) return;
for (var i = 0; i < encodedPackets.length; i++) {
self.conn.write(encodedPackets[i]);
}
@@ -180,7 +183,7 @@ Client.prototype.ondecoded = function(packet) {
debug('no socket for namespace %s', packet.nsp);
}
}
-}
+};
/**
* Called upon transport close.
View
@@ -179,7 +179,8 @@ Socket.prototype.write = function(){
Socket.prototype.packet = function(packet, preEncoded){
packet.nsp = this.nsp.name;
- this.client.packet(packet, preEncoded);
+ var volatile = this.flags && this.flags.volatile;
+ this.client.packet(packet, preEncoded, volatile);
};
/**

0 comments on commit 81e8a0c

Please sign in to comment.