|
|
@ -220,17 +220,17 @@ static NSString *const kBearerPrefix = @"Bearer "; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (void)cancel { |
|
|
|
- (void)cancel { |
|
|
|
|
|
|
|
if (!self.isWaitingForToken) { |
|
|
|
|
|
|
|
[self cancelCall]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.isWaitingForToken = NO; |
|
|
|
|
|
|
|
} |
|
|
|
[self |
|
|
|
[self |
|
|
|
maybeFinishWithError:[NSError |
|
|
|
maybeFinishWithError:[NSError |
|
|
|
errorWithDomain:kGRPCErrorDomain |
|
|
|
errorWithDomain:kGRPCErrorDomain |
|
|
|
code:GRPCErrorCodeCancelled |
|
|
|
code:GRPCErrorCodeCancelled |
|
|
|
userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; |
|
|
|
userInfo:@{NSLocalizedDescriptionKey : @"Canceled by app"}]]; |
|
|
|
|
|
|
|
|
|
|
|
if (!self.isWaitingForToken) { |
|
|
|
|
|
|
|
[self cancelCall]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.isWaitingForToken = NO; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (void)maybeFinishWithError:(NSError *)errorOrNil { |
|
|
|
- (void)maybeFinishWithError:(NSError *)errorOrNil { |
|
|
@ -292,6 +292,7 @@ static NSString *const kBearerPrefix = @"Bearer "; |
|
|
|
// don't want to throw, because the app shouldn't crash for a behavior |
|
|
|
// don't want to throw, because the app shouldn't crash for a behavior |
|
|
|
// that's on the hands of any server to have. Instead we finish and ask |
|
|
|
// that's on the hands of any server to have. Instead we finish and ask |
|
|
|
// the server to cancel. |
|
|
|
// the server to cancel. |
|
|
|
|
|
|
|
[strongSelf cancelCall]; |
|
|
|
[strongSelf |
|
|
|
[strongSelf |
|
|
|
maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
code:GRPCErrorCodeResourceExhausted |
|
|
|
code:GRPCErrorCodeResourceExhausted |
|
|
@ -300,7 +301,6 @@ static NSString *const kBearerPrefix = @"Bearer "; |
|
|
|
@"Client does not have enough memory to " |
|
|
|
@"Client does not have enough memory to " |
|
|
|
@"hold the server response." |
|
|
|
@"hold the server response." |
|
|
|
}]]; |
|
|
|
}]]; |
|
|
|
[strongSelf cancelCall]; |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
[strongWriteable enqueueValue:data |
|
|
|
[strongWriteable enqueueValue:data |
|
|
@ -530,13 +530,13 @@ static NSString *const kBearerPrefix = @"Bearer "; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (void)connectivityChanged:(NSNotification *)note { |
|
|
|
- (void)connectivityChanged:(NSNotification *)note { |
|
|
|
|
|
|
|
// Cancel underlying call upon this notification |
|
|
|
|
|
|
|
[self cancelCall]; |
|
|
|
[self maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
[self maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
code:GRPCErrorCodeUnavailable |
|
|
|
code:GRPCErrorCodeUnavailable |
|
|
|
userInfo:@{ |
|
|
|
userInfo:@{ |
|
|
|
NSLocalizedDescriptionKey : @"Connectivity lost." |
|
|
|
NSLocalizedDescriptionKey : @"Connectivity lost." |
|
|
|
}]]; |
|
|
|
}]]; |
|
|
|
// Cancel underlying call upon this notification |
|
|
|
|
|
|
|
[self cancelCall]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@end |
|
|
|
@end |
|
|
|