Chromium Code Reviews| Index: webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m |
| diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m b/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m |
| index d707b92d4486be631f5de4deab0d91e4a662aff1..62a97cd2425a55aad33f77cfa0067669c1433917 100644 |
| --- a/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m |
| +++ b/webrtc/examples/objc/AppRTCMobile/ARDAppEngineClient.m |
| @@ -57,29 +57,27 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1; |
| request.HTTPMethod = @"POST"; |
| __weak ARDAppEngineClient *weakSelf = self; |
| [NSURLConnection sendAsyncRequest:request |
| - completionHandler:^(NSURLResponse *response, |
| - NSData *data, |
| - NSError *error) { |
| - ARDAppEngineClient *strongSelf = weakSelf; |
| - if (error) { |
| - if (completionHandler) { |
| - completionHandler(nil, error); |
| - } |
| - return; |
| - } |
| - ARDJoinResponse *joinResponse = |
| - [ARDJoinResponse responseFromJSONData:data]; |
| - if (!joinResponse) { |
| - if (completionHandler) { |
| - NSError *error = [[self class] badResponseError]; |
| - completionHandler(nil, error); |
| - } |
| - return; |
| - } |
| - if (completionHandler) { |
| - completionHandler(joinResponse, nil); |
| - } |
| - }]; |
| + completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { |
| + ARDAppEngineClient *strongSelf = weakSelf; |
| + if (error) { |
| + if (completionHandler) { |
| + completionHandler(nil, error); |
| + } |
| + return; |
| + } |
| + ARDJoinResponse *joinResponse = [ARDJoinResponse responseFromJSONData:data]; |
| + if (!joinResponse) { |
| + if (completionHandler) { |
| + NSError *error = [[self class] badResponseError]; |
| + completionHandler(nil, error); |
| + } |
| + return; |
| + } |
| + if (completionHandler) { |
| + completionHandler(joinResponse, nil); |
| + } |
| + |
|
daniela-webrtc
2017/03/29 12:25:56
Nit: remove extra line
kthelgason
2017/03/29 12:35:24
Done.
|
| + }]; |
| } |
| - (void)sendMessage:(ARDSignalingMessage *)message |
| @@ -138,17 +136,24 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1; |
| NSURL *url = [NSURL URLWithString:urlString]; |
| NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; |
| request.HTTPMethod = @"POST"; |
| - NSURLResponse *response = nil; |
| - NSError *error = nil; |
| + |
| + RTCLog(@"C->RS: BYE"); |
| + __block NSError *error = nil; |
| + |
| // We want a synchronous request so that we know that we've left the room on |
| // room server before we do any further work. |
| - RTCLog(@"C->RS: BYE"); |
| - [NSURLConnection sendSynchronousRequest:request |
| - returningResponse:&response |
| - error:&error]; |
| + dispatch_semaphore_t sem = dispatch_semaphore_create(0); |
| + [NSURLConnection sendAsyncRequest:request |
|
daniela-webrtc
2017/03/29 12:25:56
Is it gonna be too much work to update to NSURLSes
kthelgason
2017/03/29 12:35:25
This is actually using NSURLSession, it's calling
|
| + completionHandler:^(NSURLResponse *response, NSData *data, NSError *e) { |
| + if (e) { |
| + error = e; |
| + } |
| + dispatch_semaphore_signal(sem); |
| + }]; |
| + |
| + dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); |
| if (error) { |
| - RTCLogError(@"Error leaving room %@ on room server: %@", |
| - roomId, error.localizedDescription); |
| + RTCLogError(@"Error leaving room %@ on room server: %@", roomId, error.localizedDescription); |
| if (completionHandler) { |
| completionHandler(error); |
| } |