Fixed a couple of incorrect "this" references in Node library

pull/3345/head
murgatroid99 9 years ago
parent e8659971a9
commit a59ee9a307
  1. 6
      src/node/src/server.js

@ -276,6 +276,7 @@ function ServerWritableStream(call, serialize) {
function _write(chunk, encoding, callback) { function _write(chunk, encoding, callback) {
/* jshint validthis: true */ /* jshint validthis: true */
var batch = {}; var batch = {};
var self = this;
if (!this.call.metadataSent) { if (!this.call.metadataSent) {
batch[grpc.opType.SEND_INITIAL_METADATA] = batch[grpc.opType.SEND_INITIAL_METADATA] =
(new Metadata())._getCoreRepresentation(); (new Metadata())._getCoreRepresentation();
@ -290,7 +291,7 @@ function _write(chunk, encoding, callback) {
batch[grpc.opType.SEND_MESSAGE] = message; batch[grpc.opType.SEND_MESSAGE] = message;
this.call.startBatch(batch, function(err, value) { this.call.startBatch(batch, function(err, value) {
if (err) { if (err) {
this.emit('error', err); self.emit('error', err);
return; return;
} }
callback(); callback();
@ -305,6 +306,7 @@ ServerWritableStream.prototype._write = _write;
*/ */
function sendMetadata(responseMetadata) { function sendMetadata(responseMetadata) {
/* jshint validthis: true */ /* jshint validthis: true */
var self = this;
if (!this.call.metadataSent) { if (!this.call.metadataSent) {
this.call.metadataSent = true; this.call.metadataSent = true;
var batch = []; var batch = [];
@ -312,7 +314,7 @@ function sendMetadata(responseMetadata) {
responseMetadata._getCoreRepresentation(); responseMetadata._getCoreRepresentation();
this.call.startBatch(batch, function(err) { this.call.startBatch(batch, function(err) {
if (err) { if (err) {
this.emit('error', err); self.emit('error', err);
return; return;
} }
}); });

Loading…
Cancel
Save