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

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

Issue 2780433006: Fix deprecated methods in AppRTCMobile. (Closed)
Patch Set: fix nits Created 3 years, 8 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
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | webrtc/examples/objc/AppRTCMobile/common/ARDUtilities.m » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 urlString = 50 urlString =
51 [NSString stringWithFormat:kARDRoomServerJoinFormat, roomId]; 51 [NSString stringWithFormat:kARDRoomServerJoinFormat, roomId];
52 } 52 }
53 53
54 NSURL *roomURL = [NSURL URLWithString:urlString]; 54 NSURL *roomURL = [NSURL URLWithString:urlString];
55 RTCLog(@"Joining room:%@ on room server.", roomId); 55 RTCLog(@"Joining room:%@ on room server.", roomId);
56 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL]; 56 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
57 request.HTTPMethod = @"POST"; 57 request.HTTPMethod = @"POST";
58 __weak ARDAppEngineClient *weakSelf = self; 58 __weak ARDAppEngineClient *weakSelf = self;
59 [NSURLConnection sendAsyncRequest:request 59 [NSURLConnection sendAsyncRequest:request
60 completionHandler:^(NSURLResponse *response, 60 completionHandler:^(NSURLResponse *response, NSData *data, NSE rror *error) {
61 NSData *data, 61 ARDAppEngineClient *strongSelf = weakSelf;
62 NSError *error) { 62 if (error) {
63 ARDAppEngineClient *strongSelf = weakSelf; 63 if (completionHandler) {
64 if (error) { 64 completionHandler(nil, error);
65 if (completionHandler) { 65 }
66 completionHandler(nil, error); 66 return;
67 } 67 }
68 return; 68 ARDJoinResponse *joinResponse = [ARDJoinResponse responseFro mJSONData:data];
69 } 69 if (!joinResponse) {
70 ARDJoinResponse *joinResponse = 70 if (completionHandler) {
71 [ARDJoinResponse responseFromJSONData:data]; 71 NSError *error = [[self class] badResponseError];
72 if (!joinResponse) { 72 completionHandler(nil, error);
73 if (completionHandler) { 73 }
74 NSError *error = [[self class] badResponseError]; 74 return;
75 completionHandler(nil, error); 75 }
76 } 76 if (completionHandler) {
77 return; 77 completionHandler(joinResponse, nil);
78 } 78 }
79 if (completionHandler) { 79 }];
80 completionHandler(joinResponse, nil);
81 }
82 }];
83 } 80 }
84 81
85 - (void)sendMessage:(ARDSignalingMessage *)message 82 - (void)sendMessage:(ARDSignalingMessage *)message
86 forRoomId:(NSString *)roomId 83 forRoomId:(NSString *)roomId
87 clientId:(NSString *)clientId 84 clientId:(NSString *)clientId
88 completionHandler:(void (^)(ARDMessageResponse *response, 85 completionHandler:(void (^)(ARDMessageResponse *response,
89 NSError *error))completionHandler { 86 NSError *error))completionHandler {
90 NSParameterAssert(message); 87 NSParameterAssert(message);
91 NSParameterAssert(roomId.length); 88 NSParameterAssert(roomId.length);
92 NSParameterAssert(clientId.length); 89 NSParameterAssert(clientId.length);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 clientId:(NSString *)clientId 128 clientId:(NSString *)clientId
132 completionHandler:(void (^)(NSError *error))completionHandler { 129 completionHandler:(void (^)(NSError *error))completionHandler {
133 NSParameterAssert(roomId.length); 130 NSParameterAssert(roomId.length);
134 NSParameterAssert(clientId.length); 131 NSParameterAssert(clientId.length);
135 132
136 NSString *urlString = 133 NSString *urlString =
137 [NSString stringWithFormat:kARDRoomServerLeaveFormat, roomId, clientId]; 134 [NSString stringWithFormat:kARDRoomServerLeaveFormat, roomId, clientId];
138 NSURL *url = [NSURL URLWithString:urlString]; 135 NSURL *url = [NSURL URLWithString:urlString];
139 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 136 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
140 request.HTTPMethod = @"POST"; 137 request.HTTPMethod = @"POST";
141 NSURLResponse *response = nil; 138
142 NSError *error = nil; 139 RTCLog(@"C->RS: BYE");
140 __block NSError *error = nil;
141
143 // We want a synchronous request so that we know that we've left the room on 142 // We want a synchronous request so that we know that we've left the room on
144 // room server before we do any further work. 143 // room server before we do any further work.
145 RTCLog(@"C->RS: BYE"); 144 dispatch_semaphore_t sem = dispatch_semaphore_create(0);
magjed_webrtc 2017/03/29 20:03:46 Maybe use rtc::Event instead?
kthelgason 2017/03/30 08:58:53 This is a pure ObjC file, and I'd prefer to keep i
magjed_webrtc 2017/03/30 11:19:46 Acknowledged.
146 [NSURLConnection sendSynchronousRequest:request 145 [NSURLConnection sendAsyncRequest:request
147 returningResponse:&response 146 completionHandler:^(NSURLResponse *response, NSData *data, NSE rror *e) {
148 error:&error]; 147 if (e) {
148 error = e;
149 }
150 dispatch_semaphore_signal(sem);
151 }];
152
153 dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
149 if (error) { 154 if (error) {
150 RTCLogError(@"Error leaving room %@ on room server: %@", 155 RTCLogError(@"Error leaving room %@ on room server: %@", roomId, error.local izedDescription);
151 roomId, error.localizedDescription);
152 if (completionHandler) { 156 if (completionHandler) {
153 completionHandler(error); 157 completionHandler(error);
154 } 158 }
155 return; 159 return;
156 } 160 }
157 RTCLog(@"Left room:%@ on room server.", roomId); 161 RTCLog(@"Left room:%@ on room server.", roomId);
158 if (completionHandler) { 162 if (completionHandler) {
159 completionHandler(nil); 163 completionHandler(nil);
160 } 164 }
161 } 165 }
162 166
163 #pragma mark - Private 167 #pragma mark - Private
164 168
165 + (NSError *)badResponseError { 169 + (NSError *)badResponseError {
166 NSError *error = 170 NSError *error =
167 [[NSError alloc] initWithDomain:kARDAppEngineClientErrorDomain 171 [[NSError alloc] initWithDomain:kARDAppEngineClientErrorDomain
168 code:kARDAppEngineClientErrorBadResponse 172 code:kARDAppEngineClientErrorBadResponse
169 userInfo:@{ 173 userInfo:@{
170 NSLocalizedDescriptionKey: @"Error parsing response.", 174 NSLocalizedDescriptionKey: @"Error parsing response.",
171 }]; 175 }];
172 return error; 176 return error;
173 } 177 }
174 178
175 @end 179 @end
OLDNEW
« no previous file with comments | « webrtc/examples/BUILD.gn ('k') | webrtc/examples/objc/AppRTCMobile/common/ARDUtilities.m » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698