|
|
|
@ -80,81 +80,6 @@ BOOL isRemoteInteropTest(NSString *host) { |
|
|
|
|
return [host isEqualToString:@"grpc-test.sandbox.googleapis.com"]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Convenience class to use blocks as callbacks |
|
|
|
|
@interface InteropTestsBlockCallbacks : NSObject<GRPCProtoResponseHandler> |
|
|
|
|
|
|
|
|
|
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback |
|
|
|
|
messageCallback:(void (^)(id))messageCallback |
|
|
|
|
closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback |
|
|
|
|
writeMessageCallback:(void (^)(void))writeMessageCallback; |
|
|
|
|
|
|
|
|
|
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback |
|
|
|
|
messageCallback:(void (^)(id))messageCallback |
|
|
|
|
closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback; |
|
|
|
|
|
|
|
|
|
@end |
|
|
|
|
|
|
|
|
|
@implementation InteropTestsBlockCallbacks { |
|
|
|
|
void (^_initialMetadataCallback)(NSDictionary *); |
|
|
|
|
void (^_messageCallback)(id); |
|
|
|
|
void (^_closeCallback)(NSDictionary *, NSError *); |
|
|
|
|
void (^_writeMessageCallback)(void); |
|
|
|
|
dispatch_queue_t _dispatchQueue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback |
|
|
|
|
messageCallback:(void (^)(id))messageCallback |
|
|
|
|
closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback |
|
|
|
|
writeMessageCallback:(void (^)(void))writeMessageCallback { |
|
|
|
|
if ((self = [super init])) { |
|
|
|
|
_initialMetadataCallback = initialMetadataCallback; |
|
|
|
|
_messageCallback = messageCallback; |
|
|
|
|
_closeCallback = closeCallback; |
|
|
|
|
_writeMessageCallback = writeMessageCallback; |
|
|
|
|
_dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL); |
|
|
|
|
} |
|
|
|
|
return self; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback |
|
|
|
|
messageCallback:(void (^)(id))messageCallback |
|
|
|
|
closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback { |
|
|
|
|
return [self initWithInitialMetadataCallback:initialMetadataCallback |
|
|
|
|
messageCallback:messageCallback |
|
|
|
|
closeCallback:closeCallback |
|
|
|
|
writeMessageCallback:nil]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata { |
|
|
|
|
if (_initialMetadataCallback) { |
|
|
|
|
_initialMetadataCallback(initialMetadata); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)didReceiveProtoMessage:(GPBMessage *)message { |
|
|
|
|
if (_messageCallback) { |
|
|
|
|
_messageCallback(message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error { |
|
|
|
|
if (_closeCallback) { |
|
|
|
|
_closeCallback(trailingMetadata, error); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)didWriteMessage { |
|
|
|
|
if (_writeMessageCallback) { |
|
|
|
|
_writeMessageCallback(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (dispatch_queue_t)dispatchQueue { |
|
|
|
|
return _dispatchQueue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@end |
|
|
|
|
|
|
|
|
|
@interface DefaultInterceptorFactory : NSObject<GRPCInterceptorFactory> |
|
|
|
|
|
|
|
|
|
- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager; |
|
|
|
|