diff options
author | murgatroid99 <mlumish@google.com> | 2015-09-15 09:23:55 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-09-15 09:23:55 -0700 |
commit | a59ee9a30792b8d5bb5e42b481c18f6222a67577 (patch) | |
tree | af0dd936ec944530ce294291a28b11492d182ce1 | |
parent | e8659971a9cedeccb90d39d2dfe784048baa2f19 (diff) |
Fixed a couple of incorrect "this" references in Node library
-rw-r--r-- | src/node/src/server.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/node/src/server.js b/src/node/src/server.js index b6f162adf8..70b4a9d80e 100644 --- a/src/node/src/server.js +++ b/src/node/src/server.js @@ -276,6 +276,7 @@ function ServerWritableStream(call, serialize) { function _write(chunk, encoding, callback) { /* jshint validthis: true */ var batch = {}; + var self = this; if (!this.call.metadataSent) { batch[grpc.opType.SEND_INITIAL_METADATA] = (new Metadata())._getCoreRepresentation(); @@ -290,7 +291,7 @@ function _write(chunk, encoding, callback) { batch[grpc.opType.SEND_MESSAGE] = message; this.call.startBatch(batch, function(err, value) { if (err) { - this.emit('error', err); + self.emit('error', err); return; } callback(); @@ -305,6 +306,7 @@ ServerWritableStream.prototype._write = _write; */ function sendMetadata(responseMetadata) { /* jshint validthis: true */ + var self = this; if (!this.call.metadataSent) { this.call.metadataSent = true; var batch = []; @@ -312,7 +314,7 @@ function sendMetadata(responseMetadata) { responseMetadata._getCoreRepresentation(); this.call.startBatch(batch, function(err) { if (err) { - this.emit('error', err); + self.emit('error', err); return; } }); |