Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue with "data" event conflict

  • Loading branch information...
commit 5face87d7f85525ea19a782faa31d292645f7437 1 parent 82a58db
@jfd jfd authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 index.js
View
18 index.js
@@ -193,12 +193,12 @@ Connection.prototype._writePacket = function(ch, flag, data) {
packet[7] = flag;
try {
+
if (data.length) {
- this.write(packet);
- return this.write(data);
- } else {
- return this.write(packet);
+ data.copy(packet, 8, 0);
}
+
+ return this.write(packet);
} catch (writeException) {
this.destroy(writeException);
return false;
@@ -273,7 +273,7 @@ function packetParser(data, start, end) {
break;
case DATA:
- this.emit("data", ch, flag, payload);
+ this.emit("message", ch, flag, payload);
break;
case SIGNAL:
@@ -302,6 +302,14 @@ function packetParser(data, start, end) {
}
}
+function combindBuffers(buffera, starta, enda, bufferb, startb, endb) {
+ var length = (enda - starta) + (endb - startb);
+ var newbuffer = new Buffer(length);
+ buffera.copy(newbuffer, 0, starta, enda);
+ bufferb.copy(newbuffer, (enda - starta), startb, endb);
+ return newbuffer;
+}
+
function getBinMode(modeExpr) {
var result = 0;
var match;
Please sign in to comment.
Something went wrong with that request. Please try again.