|
|
@ -141,25 +141,16 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
id<GRXWriteable> responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(id value) { |
|
|
|
id<GRXWriteable> responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(id value) { |
|
|
|
dispatch_async(self->_dispatchQueue, ^{ |
|
|
|
dispatch_async(self->_dispatchQueue, ^{ |
|
|
|
if (self->_handler) { |
|
|
|
if (self->_handler) { |
|
|
|
id<GRPCResponseHandler> handler = self->_handler; |
|
|
|
|
|
|
|
NSDictionary *headers = nil; |
|
|
|
NSDictionary *headers = nil; |
|
|
|
if (!self->_initialMetadataPublished) { |
|
|
|
if (!self->_initialMetadataPublished) { |
|
|
|
headers = self->_call.responseHeaders; |
|
|
|
headers = self->_call.responseHeaders; |
|
|
|
self->_initialMetadataPublished = YES; |
|
|
|
self->_initialMetadataPublished = YES; |
|
|
|
} |
|
|
|
} |
|
|
|
if (headers) { |
|
|
|
if (headers) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[self issueInitialMetadata:headers]; |
|
|
|
if ([handler respondsToSelector:@selector(receivedInitialMetadata:)]) { |
|
|
|
|
|
|
|
[handler receivedInitialMetadata:headers]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (value) { |
|
|
|
if (value) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[self issueMessage:value]; |
|
|
|
if ([handler respondsToSelector:@selector(receivedMessage:)]) { |
|
|
|
|
|
|
|
[handler receivedMessage:value]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -167,24 +158,15 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
completionHandler:^(NSError *errorOrNil) { |
|
|
|
completionHandler:^(NSError *errorOrNil) { |
|
|
|
dispatch_async(self->_dispatchQueue, ^{ |
|
|
|
dispatch_async(self->_dispatchQueue, ^{ |
|
|
|
if (self->_handler) { |
|
|
|
if (self->_handler) { |
|
|
|
id<GRPCResponseHandler> handler = self->_handler; |
|
|
|
|
|
|
|
NSDictionary *headers = nil; |
|
|
|
NSDictionary *headers = nil; |
|
|
|
if (!self->_initialMetadataPublished) { |
|
|
|
if (!self->_initialMetadataPublished) { |
|
|
|
headers = self->_call.responseHeaders; |
|
|
|
headers = self->_call.responseHeaders; |
|
|
|
self->_initialMetadataPublished = YES; |
|
|
|
self->_initialMetadataPublished = YES; |
|
|
|
} |
|
|
|
} |
|
|
|
if (headers) { |
|
|
|
if (headers) { |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[self issueInitialMetadata:headers]; |
|
|
|
if ([handler respondsToSelector:@selector(receivedInitialMetadata:)]) { |
|
|
|
|
|
|
|
[handler receivedInitialMetadata:headers]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
[self issueClosedWithTrailingMetadata:self->_call.responseTrailers error:errorOrNil]; |
|
|
|
if ([handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
|
|
|
|
[handler closedWithTrailingMetadata:self->_call.responseTrailers error:errorOrNil]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}]; |
|
|
|
}]; |
|
|
@ -230,6 +212,34 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)issueInitialMetadata:(NSDictionary *)initialMetadata { |
|
|
|
|
|
|
|
id<GRPCResponseHandler> handler = self->_handler; |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(receivedInitialMetadata:)]) { |
|
|
|
|
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
|
|
|
|
[handler receivedInitialMetadata:initialMetadata]; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)issueMessage:(id)message { |
|
|
|
|
|
|
|
id<GRPCResponseHandler> handler = self->_handler; |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(receivedMessage:)]) { |
|
|
|
|
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
|
|
|
|
[handler receivedMessage:message]; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata |
|
|
|
|
|
|
|
error:(NSError *)error { |
|
|
|
|
|
|
|
id<GRPCResponseHandler> handler = self->_handler; |
|
|
|
|
|
|
|
if ([handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) { |
|
|
|
|
|
|
|
dispatch_async(handler.dispatchQueue, ^{ |
|
|
|
|
|
|
|
[handler closedWithTrailingMetadata:self->_call.responseTrailers error:error]; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@end |
|
|
|
@end |
|
|
|
|
|
|
|
|
|
|
|
// The following methods of a C gRPC call object aren't reentrant, and thus |
|
|
|
// The following methods of a C gRPC call object aren't reentrant, and thus |
|
|
|