|
|
@ -144,14 +144,14 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
copiedCall = _call; |
|
|
|
copiedCall = _call; |
|
|
|
_call = nil; |
|
|
|
_call = nil; |
|
|
|
if ([_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { |
|
|
|
dispatch_async(_handler.dispatchQueue, ^{ |
|
|
|
dispatch_async(_handler.dispatchQueue, ^{ |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
copiedHandler = self->_handler; |
|
|
|
copiedHandler = self->_handler; |
|
|
|
self->_handler = nil; |
|
|
|
self->_handler = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
[copiedHandler closedWithTrailingMetadata:nil |
|
|
|
[copiedHandler didCloseWithTrailingMetadata:nil |
|
|
|
error:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
error:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
code:GRPCErrorCodeCancelled |
|
|
|
code:GRPCErrorCodeCancelled |
|
|
|
userInfo:@{ |
|
|
|
userInfo:@{ |
|
|
@ -187,7 +187,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing |
|
|
|
[call finish]; |
|
|
|
[call finish]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata { |
|
|
|
- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
if (initialMetadata != nil && [_handler respondsToSelector:@selector(initialMetadata:)]) { |
|
|
|
if (initialMetadata != nil && [_handler respondsToSelector:@selector(initialMetadata:)]) { |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
@ -195,35 +195,35 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
copiedHandler = self->_handler; |
|
|
|
copiedHandler = self->_handler; |
|
|
|
} |
|
|
|
} |
|
|
|
[copiedHandler receivedInitialMetadata:initialMetadata]; |
|
|
|
[copiedHandler didReceiveInitialMetadata:initialMetadata]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (void)receivedRawMessage:(NSData *)message { |
|
|
|
- (void)didReceiveRawMessage:(NSData *)message { |
|
|
|
if (message == nil) return; |
|
|
|
if (message == nil) return; |
|
|
|
|
|
|
|
|
|
|
|
NSError *error = nil; |
|
|
|
NSError *error = nil; |
|
|
|
GPBMessage *parsed = [_responseClass parseFromData:message error:&error]; |
|
|
|
GPBMessage *parsed = [_responseClass parseFromData:message error:&error]; |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
if (parsed && [_handler respondsToSelector:@selector(receivedProtoMessage:)]) { |
|
|
|
if (parsed && [_handler respondsToSelector:@selector(didReceiveProtoMessage:)]) { |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
copiedHandler = self->_handler; |
|
|
|
copiedHandler = self->_handler; |
|
|
|
} |
|
|
|
} |
|
|
|
[copiedHandler receivedProtoMessage:parsed]; |
|
|
|
[copiedHandler didReceiveProtoMessage:parsed]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else if (!parsed && |
|
|
|
} else if (!parsed && |
|
|
|
[_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
[_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
copiedHandler = self->_handler; |
|
|
|
copiedHandler = self->_handler; |
|
|
|
self->_handler = nil; |
|
|
|
self->_handler = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
[copiedHandler closedWithTrailingMetadata:nil |
|
|
|
[copiedHandler didCloseWithTrailingMetadata:nil |
|
|
|
error:ErrorForBadProto(message, _responseClass, error)]; |
|
|
|
error:ErrorForBadProto(message, _responseClass, error)]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
[_call cancel]; |
|
|
|
[_call cancel]; |
|
|
@ -232,16 +232,16 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { |
|
|
|
- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
if ([_handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) { |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
id<GRPCProtoResponseHandler> copiedHandler = nil; |
|
|
|
@synchronized(self) { |
|
|
|
@synchronized(self) { |
|
|
|
copiedHandler = self->_handler; |
|
|
|
copiedHandler = self->_handler; |
|
|
|
self->_handler = nil; |
|
|
|
self->_handler = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
[copiedHandler closedWithTrailingMetadata:trailingMetadata error:error]; |
|
|
|
[copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
_call = nil; |
|
|
|
_call = nil; |
|
|
|