aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2016-10-25 14:40:06 -0700
committerGravatar Muxi Yan <mxyan@google.com>2016-10-25 14:40:06 -0700
commit4f6a19b292ee90ede7a074352d9c73640f73a450 (patch)
treeb80590c52e3587909d0638aa07dea17bb6553f59 /src
parent7f7731025507cf9df3c44c05be24d65e86755a23 (diff)
Create connectivityMonitor after call is set up
Diffstat (limited to 'src')
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index 470d4f4c76..85d141aa09 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -409,9 +409,26 @@ static NSMutableDictionary *callFlags;
_state = GRXWriterStateStarted;
}
+ // Create a retain cycle so that this instance lives until the RPC finishes
+ // (or is cancelled). This makes RPCs in which the call isn't externally
+ // retained possible (as long as it is started before being autoreleased).
+ // Care is taken not to retain self strongly in any of the blocks used in this
+ // implementation, so that the life of the instance is determined by this
+ // retain cycle.
+ _retainSelf = self;
+
+ _responseWriteable =
+ [[GRXConcurrentWriteable alloc] initWithWriteable:writeable];
+
+ _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path];
+ NSAssert(_wrappedCall, @"Error allocating RPC objects. Low memory?");
+
+ [self sendHeaders:_requestHeaders];
+ [self invokeCall];
+
// TODO(jcanizales): Extract this logic somewhere common.
NSString *host =
- [NSURL URLWithString:[@"https://" stringByAppendingString:_host]].host;
+ [NSURL URLWithString:[@"https://" stringByAppendingString:_host]].host;
if (!host) {
// TODO(jcanizales): Check this on init.
[NSException raise:NSInvalidArgumentException
@@ -423,34 +440,17 @@ static NSMutableDictionary *callFlags;
typeof(self) strongSelf = weakSelf;
if (strongSelf) {
[strongSelf
- finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
- code:GRPCErrorCodeUnavailable
- userInfo:@{
- NSLocalizedDescriptionKey :
- @"Connectivity lost."
- }]];
+ finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
+ code:GRPCErrorCodeUnavailable
+ userInfo:@{
+ NSLocalizedDescriptionKey :
+ @"Connectivity lost."
+ }]];
}
};
[_connectivityMonitor handleLossWithHandler:handler
wifiStatusChangeHandler:^{
}];
-
- // Create a retain cycle so that this instance lives until the RPC finishes
- // (or is cancelled). This makes RPCs in which the call isn't externally
- // retained possible (as long as it is started before being autoreleased).
- // Care is taken not to retain self strongly in any of the blocks used in this
- // implementation, so that the life of the instance is determined by this
- // retain cycle.
- _retainSelf = self;
-
- _responseWriteable =
- [[GRXConcurrentWriteable alloc] initWithWriteable:writeable];
-
- _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path];
- NSAssert(_wrappedCall, @"Error allocating RPC objects. Low memory?");
-
- [self sendHeaders:_requestHeaders];
- [self invokeCall];
}
- (void)setState:(GRXWriterState)newState {