Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ function BinaryStream(socket, id, create, meta) {

this._closed = false;
this._ended = false;


this.bytesWritten = 0;
this.messageBytesWritten = 0;

if(create) {
// This is a stream we are creating
this._write(1, meta, this.id);
Expand Down Expand Up @@ -73,7 +76,13 @@ BinaryStream.prototype._write = function(code, data, bonus) {
return false;
}
var message = util.pack([code, data, bonus]);
return this._socket.send(message) !== false;
var dataLength = data ? data.length || 0 : 0;
var messageLength = message.length;
var self = this;
return this._socket.send(message, function() {
self.bytesWritten += dataLength;
self.messageBytesWritten += messageLength;
}) !== false;
};

BinaryStream.prototype.write = function(data) {
Expand Down