|
|
@ -33,7 +33,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions |
|
|
|
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions |
|
|
|
message:(GPBMessage *)message |
|
|
|
message:(GPBMessage *)message |
|
|
|
responseHandler:(id<GRPCResponseHandler>)handler |
|
|
|
responseHandler:(id<GRPCProtoResponseHandler>)handler |
|
|
|
callOptions:(GRPCCallOptions *)callOptions |
|
|
|
callOptions:(GRPCCallOptions *)callOptions |
|
|
|
responseClass:(Class)responseClass { |
|
|
|
responseClass:(Class)responseClass { |
|
|
|
if ((self = [super init])) { |
|
|
|
if ((self = [super init])) { |
|
|
@ -60,7 +60,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
@implementation GRPCStreamingProtoCall { |
|
|
|
@implementation GRPCStreamingProtoCall { |
|
|
|
GRPCRequestOptions *_requestOptions; |
|
|
|
GRPCRequestOptions *_requestOptions; |
|
|
|
id<GRPCResponseHandler> _handler; |
|
|
|
id<GRPCProtoResponseHandler> _handler; |
|
|
|
GRPCCallOptions *_callOptions; |
|
|
|
GRPCCallOptions *_callOptions; |
|
|
|
Class _responseClass; |
|
|
|
Class _responseClass; |
|
|
|
|
|
|
|
|
|
|
@ -69,7 +69,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions |
|
|
|
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions |
|
|
|
responseHandler:(id<GRPCResponseHandler>)handler |
|
|
|
responseHandler:(id<GRPCProtoResponseHandler>)handler |
|
|
|
callOptions:(GRPCCallOptions *)callOptions |
|
|
|
callOptions:(GRPCCallOptions *)callOptions |
|
|
|
responseClass:(Class)responseClass { |
|
|
|
responseClass:(Class)responseClass { |
|
|
|
if ((self = [super init])) { |
|
|
|
if ((self = [super init])) { |
|
|
@ -98,7 +98,8 @@ |
|
|
|
_call = nil; |
|
|
|
_call = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
if (_handler) { |
|
|
|
if (_handler) { |
|
|
|
id<GRPCResponseHandler> handler = _handler; |
|
|
|
id<GRPCProtoResponseHandler> handler = _handler; |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[handler closedWithTrailingMetadata:nil |
|
|
|
[handler closedWithTrailingMetadata:nil |
|
|
|
error:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
error:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
@ -108,6 +109,7 @@ |
|
|
|
@"Canceled by app" |
|
|
|
@"Canceled by app" |
|
|
|
}]]; |
|
|
|
}]]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
_handler = nil; |
|
|
|
_handler = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -136,27 +138,33 @@ |
|
|
|
|
|
|
|
|
|
|
|
- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata { |
|
|
|
- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata { |
|
|
|
if (_handler) { |
|
|
|
if (_handler) { |
|
|
|
id<GRPCResponseHandler> handler = _handler; |
|
|
|
id<GRPCProtoResponseHandler> handler = _handler; |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(initialMetadata:)]) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[handler receivedInitialMetadata:initialMetadata]; |
|
|
|
[handler receivedInitialMetadata:initialMetadata]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (void)receivedMessage:(NSData *)message { |
|
|
|
- (void)receivedRawMessage:(NSData *)message { |
|
|
|
if (_handler) { |
|
|
|
if (_handler) { |
|
|
|
id<GRPCResponseHandler> handler = _handler; |
|
|
|
id<GRPCProtoResponseHandler> handler = _handler; |
|
|
|
NSError *error = nil; |
|
|
|
NSError *error = nil; |
|
|
|
id parsed = [_responseClass parseFromData:message error:&error]; |
|
|
|
id parsed = [_responseClass parseFromData:message error:&error]; |
|
|
|
if (parsed) { |
|
|
|
if (parsed) { |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(receivedProtoMessage:)]) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[handler receivedMessage:parsed]; |
|
|
|
[handler receivedProtoMessage:parsed]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[handler closedWithTrailingMetadata:nil error:error]; |
|
|
|
[handler closedWithTrailingMetadata:nil error:error]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
handler = nil; |
|
|
|
} |
|
|
|
|
|
|
|
_handler = nil; |
|
|
|
[_call cancel]; |
|
|
|
[_call cancel]; |
|
|
|
_call = nil; |
|
|
|
_call = nil; |
|
|
|
} |
|
|
|
} |
|
|
@ -165,17 +173,17 @@ |
|
|
|
|
|
|
|
|
|
|
|
- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { |
|
|
|
- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { |
|
|
|
if (_handler) { |
|
|
|
if (_handler) { |
|
|
|
id<GRPCResponseHandler> handler = _handler; |
|
|
|
id<GRPCProtoResponseHandler> handler = _handler; |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[handler closedWithTrailingMetadata:trailingMetadata error:error]; |
|
|
|
[handler closedWithTrailingMetadata:trailingMetadata error:error]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
_handler = nil; |
|
|
|
_handler = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
if (_call) { |
|
|
|
|
|
|
|
[_call cancel]; |
|
|
|
[_call cancel]; |
|
|
|
_call = nil; |
|
|
|
_call = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (dispatch_queue_t)dispatchQueue { |
|
|
|
- (dispatch_queue_t)dispatchQueue { |
|
|
|
return _dispatchQueue; |
|
|
|
return _dispatchQueue; |
|
|
|