Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: webrtc/examples/objc/AppRTCDemo/ARDAppEngineClient.m

Issue 1334003002: Loopback mode for AppRTCDemo on iOS. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add call options header and start call button Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #import "ARDAppEngineClient.h" 11 #import "ARDAppEngineClient.h"
12 12
13 #import "RTCLogging.h" 13 #import "RTCLogging.h"
14 14
15 #import "ARDJoinResponse.h" 15 #import "ARDJoinResponse.h"
16 #import "ARDMessageResponse.h" 16 #import "ARDMessageResponse.h"
17 #import "ARDSignalingMessage.h" 17 #import "ARDSignalingMessage.h"
18 #import "ARDUtilities.h" 18 #import "ARDUtilities.h"
19 19
20 // TODO(tkchin): move these to a configuration object. 20 // TODO(tkchin): move these to a configuration object.
21 static NSString * const kARDRoomServerHostUrl = 21 static NSString * const kARDRoomServerHostUrl =
22 @"https://apprtc.appspot.com"; 22 @"https://apprtc.appspot.com";
23 static NSString * const kARDRoomServerJoinFormat = 23 static NSString * const kARDRoomServerJoinFormat =
24 @"https://apprtc.appspot.com/join/%@"; 24 @"https://apprtc.appspot.com/join/%@";
25 static NSString * const kARDRoomServerJoinFormatLoopback =
26 @"https://apprtc.appspot.com/join/%@?debug=loopback";
25 static NSString * const kARDRoomServerMessageFormat = 27 static NSString * const kARDRoomServerMessageFormat =
26 @"https://apprtc.appspot.com/message/%@/%@"; 28 @"https://apprtc.appspot.com/message/%@/%@";
27 static NSString * const kARDRoomServerLeaveFormat = 29 static NSString * const kARDRoomServerLeaveFormat =
28 @"https://apprtc.appspot.com/leave/%@/%@"; 30 @"https://apprtc.appspot.com/leave/%@/%@";
29 31
30 static NSString * const kARDAppEngineClientErrorDomain = @"ARDAppEngineClient"; 32 static NSString * const kARDAppEngineClientErrorDomain = @"ARDAppEngineClient";
31 static NSInteger const kARDAppEngineClientErrorBadResponse = -1; 33 static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
32 34
33 @implementation ARDAppEngineClient 35 @implementation ARDAppEngineClient
34 36
35 #pragma mark - ARDRoomServerClient 37 #pragma mark - ARDRoomServerClient
36 38
37 - (void)joinRoomWithRoomId:(NSString *)roomId 39 - (void)joinRoomWithRoomId:(NSString *)roomId
40 isLoopback:(BOOL)isLoopback
38 completionHandler:(void (^)(ARDJoinResponse *response, 41 completionHandler:(void (^)(ARDJoinResponse *response,
39 NSError *error))completionHandler { 42 NSError *error))completionHandler {
40 NSParameterAssert(roomId.length); 43 NSParameterAssert(roomId.length);
41 44
42 NSString *urlString = 45 NSString *urlString = nil;
43 [NSString stringWithFormat:kARDRoomServerJoinFormat, roomId]; 46 if (isLoopback) {
47 urlString =
48 [NSString stringWithFormat:kARDRoomServerJoinFormatLoopback, roomId];
49 } else {
50 urlString =
51 [NSString stringWithFormat:kARDRoomServerJoinFormat, roomId];
52 }
53
44 NSURL *roomURL = [NSURL URLWithString:urlString]; 54 NSURL *roomURL = [NSURL URLWithString:urlString];
45 RTCLog(@"Joining room:%@ on room server.", roomId); 55 RTCLog(@"Joining room:%@ on room server.", roomId);
46 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL]; 56 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
47 request.HTTPMethod = @"POST"; 57 request.HTTPMethod = @"POST";
48 __weak ARDAppEngineClient *weakSelf = self; 58 __weak ARDAppEngineClient *weakSelf = self;
49 [NSURLConnection sendAsyncRequest:request 59 [NSURLConnection sendAsyncRequest:request
50 completionHandler:^(NSURLResponse *response, 60 completionHandler:^(NSURLResponse *response,
51 NSData *data, 61 NSData *data,
52 NSError *error) { 62 NSError *error) {
53 ARDAppEngineClient *strongSelf = weakSelf; 63 ARDAppEngineClient *strongSelf = weakSelf;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 NSError *error = 166 NSError *error =
157 [[NSError alloc] initWithDomain:kARDAppEngineClientErrorDomain 167 [[NSError alloc] initWithDomain:kARDAppEngineClientErrorDomain
158 code:kARDAppEngineClientErrorBadResponse 168 code:kARDAppEngineClientErrorBadResponse
159 userInfo:@{ 169 userInfo:@{
160 NSLocalizedDescriptionKey: @"Error parsing response.", 170 NSLocalizedDescriptionKey: @"Error parsing response.",
161 }]; 171 }];
162 return error; 172 return error;
163 } 173 }
164 174
165 @end 175 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698