|
|
@ -562,10 +562,12 @@ void Call::DestroyCall() { |
|
|
|
Call::Call(grpc_call *call) : wrapped_call(call), |
|
|
|
Call::Call(grpc_call *call) : wrapped_call(call), |
|
|
|
pending_batches(0), |
|
|
|
pending_batches(0), |
|
|
|
has_final_op_completed(false) { |
|
|
|
has_final_op_completed(false) { |
|
|
|
|
|
|
|
peer = grpc_call_get_peer(call); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Call::~Call() { |
|
|
|
Call::~Call() { |
|
|
|
DestroyCall(); |
|
|
|
DestroyCall(); |
|
|
|
|
|
|
|
gpr_free(peer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Call::Init(Local<Object> exports) { |
|
|
|
void Call::Init(Local<Object> exports) { |
|
|
@ -794,6 +796,11 @@ NAN_METHOD(Call::Cancel) { |
|
|
|
return Nan::ThrowTypeError("cancel can only be called on Call objects"); |
|
|
|
return Nan::ThrowTypeError("cancel can only be called on Call objects"); |
|
|
|
} |
|
|
|
} |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
|
|
|
|
if (call->wrapped_call == NULL) { |
|
|
|
|
|
|
|
/* Cancel is supposed to be idempotent. If the call has already finished,
|
|
|
|
|
|
|
|
* cancel should just complete silently */ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
grpc_call_error error = grpc_call_cancel(call->wrapped_call, NULL); |
|
|
|
grpc_call_error error = grpc_call_cancel(call->wrapped_call, NULL); |
|
|
|
if (error != GRPC_CALL_OK) { |
|
|
|
if (error != GRPC_CALL_OK) { |
|
|
|
return Nan::ThrowError(nanErrorWithCode("cancel failed", error)); |
|
|
|
return Nan::ThrowError(nanErrorWithCode("cancel failed", error)); |
|
|
@ -814,6 +821,11 @@ NAN_METHOD(Call::CancelWithStatus) { |
|
|
|
"cancelWithStatus's second argument must be a string"); |
|
|
|
"cancelWithStatus's second argument must be a string"); |
|
|
|
} |
|
|
|
} |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
|
|
|
|
if (call->wrapped_call == NULL) { |
|
|
|
|
|
|
|
/* Cancel is supposed to be idempotent. If the call has already finished,
|
|
|
|
|
|
|
|
* cancel should just complete silently */ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
grpc_status_code code = static_cast<grpc_status_code>( |
|
|
|
grpc_status_code code = static_cast<grpc_status_code>( |
|
|
|
Nan::To<uint32_t>(info[0]).FromJust()); |
|
|
|
Nan::To<uint32_t>(info[0]).FromJust()); |
|
|
|
if (code == GRPC_STATUS_OK) { |
|
|
|
if (code == GRPC_STATUS_OK) { |
|
|
@ -830,9 +842,7 @@ NAN_METHOD(Call::GetPeer) { |
|
|
|
return Nan::ThrowTypeError("getPeer can only be called on Call objects"); |
|
|
|
return Nan::ThrowTypeError("getPeer can only be called on Call objects"); |
|
|
|
} |
|
|
|
} |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
char *peer = grpc_call_get_peer(call->wrapped_call); |
|
|
|
Local<Value> peer_value = Nan::New(call->peer).ToLocalChecked(); |
|
|
|
Local<Value> peer_value = Nan::New(peer).ToLocalChecked(); |
|
|
|
|
|
|
|
gpr_free(peer); |
|
|
|
|
|
|
|
info.GetReturnValue().Set(peer_value); |
|
|
|
info.GetReturnValue().Set(peer_value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -847,6 +857,10 @@ NAN_METHOD(Call::SetCredentials) { |
|
|
|
"setCredentials' first argument must be a CallCredentials"); |
|
|
|
"setCredentials' first argument must be a CallCredentials"); |
|
|
|
} |
|
|
|
} |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
Call *call = ObjectWrap::Unwrap<Call>(info.This()); |
|
|
|
|
|
|
|
if (call->wrapped_call == NULL) { |
|
|
|
|
|
|
|
return Nan::ThrowError( |
|
|
|
|
|
|
|
"Cannot set credentials on a call that has already started"); |
|
|
|
|
|
|
|
} |
|
|
|
CallCredentials *creds_object = ObjectWrap::Unwrap<CallCredentials>( |
|
|
|
CallCredentials *creds_object = ObjectWrap::Unwrap<CallCredentials>( |
|
|
|
Nan::To<Object>(info[0]).ToLocalChecked()); |
|
|
|
Nan::To<Object>(info[0]).ToLocalChecked()); |
|
|
|
grpc_call_credentials *creds = creds_object->GetWrappedCredentials(); |
|
|
|
grpc_call_credentials *creds = creds_object->GetWrappedCredentials(); |
|
|
|