pull/9247/head
Muxi Yan 8 years ago
parent a40ccd8580
commit bf803b9563
  1. 24
      src/objective-c/GRPCClient/GRPCCall.m

@ -164,8 +164,8 @@ static NSMutableDictionary *callFlags;
_requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self]; _requestHeaders = [[GRPCRequestHeaders alloc] initWithCall:self];
if ([requestWriter isKindOfClass:[GRXImmediateSingleWriter class]]) { if ([requestWriter isKindOfClass:[GRXImmediateSingleWriter class]]) {
_unaryCall = true; _unaryCall = YES;
_unaryOpBatch = [[NSMutableArray alloc] init]; _unaryOpBatch = [NSMutableArray arrayWithCapacity:6];
} }
} }
return self; return self;
@ -267,14 +267,13 @@ static NSMutableDictionary *callFlags;
- (void)sendHeaders:(NSDictionary *)headers { - (void)sendHeaders:(NSDictionary *)headers {
// TODO(jcanizales): Add error handlers for async failures // TODO(jcanizales): Add error handlers for async failures
if (!_unaryCall) { GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] initWithMetadata:headers
[_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMetadata alloc] initWithMetadata:headers
flags:[GRPCCall callFlagsForHost:_host path:_path] flags:[GRPCCall callFlagsForHost:_host path:_path]
handler:nil]]]; handler:nil];
if (!_unaryCall) {
[_wrappedCall startBatchWithOperations:@[op]];
} else { } else {
[_unaryOpBatch addObject:[[GRPCOpSendMetadata alloc] initWithMetadata:headers [_unaryOpBatch addObject:op];
flags:[GRPCCall callFlagsForHost:_host path:_path]
handler:nil]];
} }
} }
@ -294,13 +293,14 @@ static NSMutableDictionary *callFlags;
} }
} }
}; };
GRPCOpSendMessage *op = [[GRPCOpSendMessage alloc] initWithMessage:message
handler:resumingHandler];
if (!_unaryCall) { if (!_unaryCall) {
[_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMessage alloc] initWithMessage:message [_wrappedCall startBatchWithOperations:@[op]
handler:resumingHandler]]
errorHandler:errorHandler]; errorHandler:errorHandler];
} else { } else {
[_unaryOpBatch addObject:[[GRPCOpSendMessage alloc] initWithMessage:message [_unaryOpBatch addObject:op];
handler:resumingHandler]];
} }
} }

Loading…
Cancel
Save