Skip to content

Commit

Permalink
Merge pull request #9 from naeims/master
Browse files Browse the repository at this point in the history
Fix stream.write() and server.emit() overrides to call the original methods with the correct this context
  • Loading branch information
rohiniwork committed Feb 11, 2014
2 parents 276c1b3 + 176d80c commit 9134b17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/monitor.js
Expand Up @@ -47,7 +47,7 @@ ReqCounter.prototype.registerEvents = function (server) {
server.emit = function () { server.emit = function () {
var args = arguments; var args = arguments;
if (args[0] !== 'connection' && args[0] !== 'request') { if (args[0] !== 'connection' && args[0] !== 'request') {
origEmit.apply(server, arguments); origEmit.apply(this, arguments);
return; return;
} }


Expand All @@ -65,7 +65,7 @@ ReqCounter.prototype.registerEvents = function (server) {
if (data && data.length) { if (data && data.length) {
that._transfered += data.length; that._transfered += data.length;
} }
origWrite.apply(stream, arguments); origWrite.apply(this, arguments);
}; };


stream.on('close', function () { stream.on('close', function () {
Expand Down Expand Up @@ -103,7 +103,7 @@ ReqCounter.prototype.registerEvents = function (server) {
}; };
/*jslint plusplus:true*/ /*jslint plusplus:true*/
} }
origEmit.apply(server, arguments); origEmit.apply(this, arguments);
}; };
}; };


Expand Down

0 comments on commit 9134b17

Please sign in to comment.