mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Merged from release_0.11
This commit is contained in:
commit
421706f822
@ -184,6 +184,9 @@ Local<Value> Op::GetOpType() const {
|
||||
return scope.Escape(Nan::New(GetTypeString()).ToLocalChecked());
|
||||
}
|
||||
|
||||
Op::~Op() {
|
||||
}
|
||||
|
||||
class SendMetadataOp : public Op {
|
||||
public:
|
||||
Local<Value> GetNodeValue() const {
|
||||
@ -359,7 +362,7 @@ class ReadMessageOp : public Op {
|
||||
}
|
||||
~ReadMessageOp() {
|
||||
if (recv_message != NULL) {
|
||||
gpr_free(recv_message);
|
||||
grpc_byte_buffer_destroy(recv_message);
|
||||
}
|
||||
}
|
||||
Local<Value> GetNodeValue() const {
|
||||
|
||||
@ -78,6 +78,7 @@ class Op {
|
||||
virtual v8::Local<v8::Value> GetNodeValue() const = 0;
|
||||
virtual bool ParseOp(v8::Local<v8::Value> value, grpc_op *out,
|
||||
shared_ptr<Resources> resources) = 0;
|
||||
virtual ~Op();
|
||||
v8::Local<v8::Value> GetOpType() const;
|
||||
|
||||
protected:
|
||||
@ -85,7 +86,6 @@ class Op {
|
||||
};
|
||||
|
||||
typedef std::vector<unique_ptr<Op>> OpVec;
|
||||
|
||||
struct tag {
|
||||
tag(Nan::Callback *callback, OpVec *ops,
|
||||
shared_ptr<Resources> resources);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user