Update GAE API paths for join/leave.
BUG=4221
R=jiayl@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/33069004
Cr-Commit-Position: refs/heads/master@{#8174}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8174 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/examples/objc/AppRTCDemo/ARDAppClient+Internal.h b/talk/examples/objc/AppRTCDemo/ARDAppClient+Internal.h
index 30ee549..8bb6609 100644
--- a/talk/examples/objc/AppRTCDemo/ARDAppClient+Internal.h
+++ b/talk/examples/objc/AppRTCDemo/ARDAppClient+Internal.h
@@ -48,7 +48,7 @@
@property(nonatomic, assign) BOOL isTurnComplete;
@property(nonatomic, assign) BOOL hasReceivedSdp;
-@property(nonatomic, readonly) BOOL isRegisteredWithRoomServer;
+@property(nonatomic, readonly) BOOL hasJoinedRoomServerRoom;
@property(nonatomic, strong) NSString *roomId;
@property(nonatomic, strong) NSString *clientId;
diff --git a/talk/examples/objc/AppRTCDemo/ARDAppClient.m b/talk/examples/objc/AppRTCDemo/ARDAppClient.m
index 4b10b7d..5539adb 100644
--- a/talk/examples/objc/AppRTCDemo/ARDAppClient.m
+++ b/talk/examples/objc/AppRTCDemo/ARDAppClient.m
@@ -31,8 +31,8 @@
#import "ARDAppEngineClient.h"
#import "ARDCEODTURNClient.h"
+#import "ARDJoinResponse.h"
#import "ARDMessageResponse.h"
-#import "ARDRegisterResponse.h"
#import "ARDSignalingMessage.h"
#import "ARDUtilities.h"
#import "ARDWebSocketChannel.h"
@@ -149,23 +149,23 @@
[strongSelf startSignalingIfReady];
}];
- // Register with room server.
- [_roomServerClient registerForRoomId:roomId
- completionHandler:^(ARDRegisterResponse *response, NSError *error) {
+ // Join room on room server.
+ [_roomServerClient joinRoomWithRoomId:roomId
+ completionHandler:^(ARDJoinResponse *response, NSError *error) {
ARDAppClient *strongSelf = weakSelf;
if (error) {
[strongSelf.delegate appClient:strongSelf didError:error];
return;
}
- NSError *registerError =
- [[strongSelf class] errorForRegisterResultType:response.result];
- if (registerError) {
- NSLog(@"Failed to register with room server.");
+ NSError *joinError =
+ [[strongSelf class] errorForJoinResultType:response.result];
+ if (joinError) {
+ NSLog(@"Failed to join room:%@ on room server.", roomId);
[strongSelf disconnect];
- [strongSelf.delegate appClient:strongSelf didError:registerError];
+ [strongSelf.delegate appClient:strongSelf didError:joinError];
return;
}
- NSLog(@"Registered with room server.");
+ NSLog(@"Joined room:%@ on room server.", roomId);
strongSelf.roomId = response.roomId;
strongSelf.clientId = response.clientId;
strongSelf.isInitiator = response.isInitiator;
@@ -189,8 +189,8 @@
if (_state == kARDAppClientStateDisconnected) {
return;
}
- if (self.isRegisteredWithRoomServer) {
- [_roomServerClient deregisterForRoomId:_roomId
+ if (self.hasJoinedRoomServerRoom) {
+ [_roomServerClient leaveRoomWithRoomId:_roomId
clientId:_clientId
completionHandler:nil];
}
@@ -360,12 +360,12 @@
#pragma mark - Private
-- (BOOL)isRegisteredWithRoomServer {
+- (BOOL)hasJoinedRoomServerRoom {
return _clientId.length;
}
- (void)startSignalingIfReady {
- if (!_isTurnComplete || !self.isRegisteredWithRoomServer) {
+ if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) {
return;
}
self.state = kARDAppClientStateConnected;
@@ -496,7 +496,7 @@
#pragma mark - Collider methods
- (void)registerWithColliderIfReady {
- if (!self.isRegisteredWithRoomServer) {
+ if (!self.hasJoinedRoomServerRoom) {
return;
}
// Open WebSocket connection.
@@ -558,12 +558,12 @@
#pragma mark - Errors
-+ (NSError *)errorForRegisterResultType:(ARDRegisterResultType)resultType {
++ (NSError *)errorForJoinResultType:(ARDJoinResultType)resultType {
NSError *error = nil;
switch (resultType) {
- case kARDRegisterResultTypeSuccess:
+ case kARDJoinResultTypeSuccess:
break;
- case kARDRegisterResultTypeUnknown: {
+ case kARDJoinResultTypeUnknown: {
error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain
code:kARDAppClientErrorUnknown
userInfo:@{
@@ -571,7 +571,7 @@
}];
break;
}
- case kARDRegisterResultTypeFull: {
+ case kARDJoinResultTypeFull: {
error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain
code:kARDAppClientErrorRoomFull
userInfo:@{
diff --git a/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m b/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m
index 4871c27..c647ecb 100644
--- a/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m
+++ b/talk/examples/objc/AppRTCDemo/ARDAppEngineClient.m
@@ -27,20 +27,20 @@
#import "ARDAppEngineClient.h"
+#import "ARDJoinResponse.h"
#import "ARDMessageResponse.h"
-#import "ARDRegisterResponse.h"
#import "ARDSignalingMessage.h"
#import "ARDUtilities.h"
// TODO(tkchin): move these to a configuration object.
static NSString *kARDRoomServerHostUrl =
@"https://apprtc.appspot.com";
-static NSString *kARDRoomServerRegisterFormat =
- @"https://apprtc.appspot.com/register/%@";
+static NSString *kARDRoomServerJoinFormat =
+ @"https://apprtc.appspot.com/join/%@";
static NSString *kARDRoomServerMessageFormat =
@"https://apprtc.appspot.com/message/%@/%@";
-static NSString *kARDRoomServerByeFormat =
- @"https://apprtc.appspot.com/bye/%@/%@";
+static NSString *kARDRoomServerLeaveFormat =
+ @"https://apprtc.appspot.com/leave/%@/%@";
static NSString *kARDAppEngineClientErrorDomain = @"ARDAppEngineClient";
static NSInteger kARDAppEngineClientErrorBadResponse = -1;
@@ -49,15 +49,15 @@
#pragma mark - ARDRoomServerClient
-- (void)registerForRoomId:(NSString *)roomId
- completionHandler:(void (^)(ARDRegisterResponse *response,
- NSError *error))completionHandler {
+- (void)joinRoomWithRoomId:(NSString *)roomId
+ completionHandler:(void (^)(ARDJoinResponse *response,
+ NSError *error))completionHandler {
NSParameterAssert(roomId.length);
NSString *urlString =
- [NSString stringWithFormat:kARDRoomServerRegisterFormat, roomId];
+ [NSString stringWithFormat:kARDRoomServerJoinFormat, roomId];
NSURL *roomURL = [NSURL URLWithString:urlString];
- NSLog(@"Registering with room server.");
+ NSLog(@"Joining room:%@ on room server.", roomId);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
request.HTTPMethod = @"POST";
__weak ARDAppEngineClient *weakSelf = self;
@@ -72,9 +72,9 @@
}
return;
}
- ARDRegisterResponse *registerResponse =
- [ARDRegisterResponse responseFromJSONData:data];
- if (!registerResponse) {
+ ARDJoinResponse *joinResponse =
+ [ARDJoinResponse responseFromJSONData:data];
+ if (!joinResponse) {
if (completionHandler) {
NSError *error = [[self class] badResponseError];
completionHandler(nil, error);
@@ -82,7 +82,7 @@
return;
}
if (completionHandler) {
- completionHandler(registerResponse, nil);
+ completionHandler(joinResponse, nil);
}
}];
}
@@ -132,32 +132,33 @@
}];
}
-- (void)deregisterForRoomId:(NSString *)roomId
+- (void)leaveRoomWithRoomId:(NSString *)roomId
clientId:(NSString *)clientId
completionHandler:(void (^)(NSError *error))completionHandler {
NSParameterAssert(roomId.length);
NSParameterAssert(clientId.length);
NSString *urlString =
- [NSString stringWithFormat:kARDRoomServerByeFormat, roomId, clientId];
+ [NSString stringWithFormat:kARDRoomServerLeaveFormat, roomId, clientId];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLResponse *response = nil;
NSError *error = nil;
- // We want a synchronous request so that we know that we're unregistered from
- // room server before we do any further unregistration.
+ // We want a synchronous request so that we know that we've left the room on
+ // room server before we do any further work.
NSLog(@"C->RS: BYE");
[NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
if (error) {
- NSLog(@"Error unregistering from room server: %@", error);
+ NSLog(@"Error leaving room %@ on room server: %@",
+ roomId, error.localizedDescription);
if (completionHandler) {
completionHandler(error);
}
return;
}
- NSLog(@"Unregistered from room server.");
+ NSLog(@"Left room:%@ on room server.", roomId);
if (completionHandler) {
completionHandler(nil);
}
diff --git a/talk/examples/objc/AppRTCDemo/ARDRegisterResponse+Internal.h b/talk/examples/objc/AppRTCDemo/ARDJoinResponse+Internal.h
similarity index 93%
rename from talk/examples/objc/AppRTCDemo/ARDRegisterResponse+Internal.h
rename to talk/examples/objc/AppRTCDemo/ARDJoinResponse+Internal.h
index 05cbde5..5f82414 100644
--- a/talk/examples/objc/AppRTCDemo/ARDRegisterResponse+Internal.h
+++ b/talk/examples/objc/AppRTCDemo/ARDJoinResponse+Internal.h
@@ -25,11 +25,11 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import "ARDRegisterResponse.h"
+#import "ARDJoinResponse.h"
-@interface ARDRegisterResponse ()
+@interface ARDJoinResponse ()
-@property(nonatomic, assign) ARDRegisterResultType result;
+@property(nonatomic, assign) ARDJoinResultType result;
@property(nonatomic, assign) BOOL isInitiator;
@property(nonatomic, strong) NSString *roomId;
@property(nonatomic, strong) NSString *clientId;
diff --git a/talk/examples/objc/AppRTCDemo/ARDRegisterResponse.h b/talk/examples/objc/AppRTCDemo/ARDJoinResponse.h
similarity index 83%
rename from talk/examples/objc/AppRTCDemo/ARDRegisterResponse.h
rename to talk/examples/objc/AppRTCDemo/ARDJoinResponse.h
index 0dbf7fb..8b12eb8 100644
--- a/talk/examples/objc/AppRTCDemo/ARDRegisterResponse.h
+++ b/talk/examples/objc/AppRTCDemo/ARDJoinResponse.h
@@ -27,16 +27,16 @@
#import <Foundation/Foundation.h>
-typedef NS_ENUM(NSInteger, ARDRegisterResultType) {
- kARDRegisterResultTypeUnknown,
- kARDRegisterResultTypeSuccess,
- kARDRegisterResultTypeFull
+typedef NS_ENUM(NSInteger, ARDJoinResultType) {
+ kARDJoinResultTypeUnknown,
+ kARDJoinResultTypeSuccess,
+ kARDJoinResultTypeFull
};
-// Result of registering with the GAE server.
-@interface ARDRegisterResponse : NSObject
+// Result of joining a room on the room server.
+@interface ARDJoinResponse : NSObject
-@property(nonatomic, readonly) ARDRegisterResultType result;
+@property(nonatomic, readonly) ARDJoinResultType result;
@property(nonatomic, readonly) BOOL isInitiator;
@property(nonatomic, readonly) NSString *roomId;
@property(nonatomic, readonly) NSString *clientId;
@@ -44,6 +44,6 @@
@property(nonatomic, readonly) NSURL *webSocketURL;
@property(nonatomic, readonly) NSURL *webSocketRestURL;
-+ (ARDRegisterResponse *)responseFromJSONData:(NSData *)data;
++ (ARDJoinResponse *)responseFromJSONData:(NSData *)data;
@end
diff --git a/talk/examples/objc/AppRTCDemo/ARDRegisterResponse.m b/talk/examples/objc/AppRTCDemo/ARDJoinResponse.m
similarity index 65%
rename from talk/examples/objc/AppRTCDemo/ARDRegisterResponse.m
rename to talk/examples/objc/AppRTCDemo/ARDJoinResponse.m
index 8d0a74c..5c15955 100644
--- a/talk/examples/objc/AppRTCDemo/ARDRegisterResponse.m
+++ b/talk/examples/objc/AppRTCDemo/ARDJoinResponse.m
@@ -25,22 +25,22 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import "ARDRegisterResponse+Internal.h"
+#import "ARDJoinResponse+Internal.h"
#import "ARDSignalingMessage.h"
#import "ARDUtilities.h"
#import "RTCICEServer+JSON.h"
-static NSString const *kARDRegisterResultKey = @"result";
-static NSString const *kARDRegisterResultParamsKey = @"params";
-static NSString const *kARDRegisterInitiatorKey = @"is_initiator";
-static NSString const *kARDRegisterRoomIdKey = @"room_id";
-static NSString const *kARDRegisterClientIdKey = @"client_id";
-static NSString const *kARDRegisterMessagesKey = @"messages";
-static NSString const *kARDRegisterWebSocketURLKey = @"wss_url";
-static NSString const *kARDRegisterWebSocketRestURLKey = @"wss_post_url";
+static NSString const *kARDJoinResultKey = @"result";
+static NSString const *kARDJoinResultParamsKey = @"params";
+static NSString const *kARDJoinInitiatorKey = @"is_initiator";
+static NSString const *kARDJoinRoomIdKey = @"room_id";
+static NSString const *kARDJoinClientIdKey = @"client_id";
+static NSString const *kARDJoinMessagesKey = @"messages";
+static NSString const *kARDJoinWebSocketURLKey = @"wss_url";
+static NSString const *kARDJoinWebSocketRestURLKey = @"wss_post_url";
-@implementation ARDRegisterResponse
+@implementation ARDJoinResponse
@synthesize result = _result;
@synthesize isInitiator = _isInitiator;
@@ -50,22 +50,22 @@
@synthesize webSocketURL = _webSocketURL;
@synthesize webSocketRestURL = _webSocketRestURL;
-+ (ARDRegisterResponse *)responseFromJSONData:(NSData *)data {
++ (ARDJoinResponse *)responseFromJSONData:(NSData *)data {
NSDictionary *responseJSON = [NSDictionary dictionaryWithJSONData:data];
if (!responseJSON) {
return nil;
}
- ARDRegisterResponse *response = [[ARDRegisterResponse alloc] init];
- NSString *resultString = responseJSON[kARDRegisterResultKey];
+ ARDJoinResponse *response = [[ARDJoinResponse alloc] init];
+ NSString *resultString = responseJSON[kARDJoinResultKey];
response.result = [[self class] resultTypeFromString:resultString];
- NSDictionary *params = responseJSON[kARDRegisterResultParamsKey];
+ NSDictionary *params = responseJSON[kARDJoinResultParamsKey];
- response.isInitiator = [params[kARDRegisterInitiatorKey] boolValue];
- response.roomId = params[kARDRegisterRoomIdKey];
- response.clientId = params[kARDRegisterClientIdKey];
+ response.isInitiator = [params[kARDJoinInitiatorKey] boolValue];
+ response.roomId = params[kARDJoinRoomIdKey];
+ response.clientId = params[kARDJoinClientIdKey];
// Parse messages.
- NSArray *messages = params[kARDRegisterMessagesKey];
+ NSArray *messages = params[kARDJoinMessagesKey];
NSMutableArray *signalingMessages =
[NSMutableArray arrayWithCapacity:messages.count];
for (NSString *message in messages) {
@@ -76,9 +76,9 @@
response.messages = signalingMessages;
// Parse websocket urls.
- NSString *webSocketURLString = params[kARDRegisterWebSocketURLKey];
+ NSString *webSocketURLString = params[kARDJoinWebSocketURLKey];
response.webSocketURL = [NSURL URLWithString:webSocketURLString];
- NSString *webSocketRestURLString = params[kARDRegisterWebSocketRestURLKey];
+ NSString *webSocketRestURLString = params[kARDJoinWebSocketRestURLKey];
response.webSocketRestURL = [NSURL URLWithString:webSocketRestURLString];
return response;
@@ -86,12 +86,12 @@
#pragma mark - Private
-+ (ARDRegisterResultType)resultTypeFromString:(NSString *)resultString {
- ARDRegisterResultType result = kARDRegisterResultTypeUnknown;
++ (ARDJoinResultType)resultTypeFromString:(NSString *)resultString {
+ ARDJoinResultType result = kARDJoinResultTypeUnknown;
if ([resultString isEqualToString:@"SUCCESS"]) {
- result = kARDRegisterResultTypeSuccess;
+ result = kARDJoinResultTypeSuccess;
} else if ([resultString isEqualToString:@"FULL"]) {
- result = kARDRegisterResultTypeFull;
+ result = kARDJoinResultTypeFull;
}
return result;
}
diff --git a/talk/examples/objc/AppRTCDemo/ARDRoomServerClient.h b/talk/examples/objc/AppRTCDemo/ARDRoomServerClient.h
index 84dc25c..68d92ab 100644
--- a/talk/examples/objc/AppRTCDemo/ARDRoomServerClient.h
+++ b/talk/examples/objc/AppRTCDemo/ARDRoomServerClient.h
@@ -27,15 +27,15 @@
#import <Foundation/Foundation.h>
+@class ARDJoinResponse;
@class ARDMessageResponse;
-@class ARDRegisterResponse;
@class ARDSignalingMessage;
@protocol ARDRoomServerClient <NSObject>
-- (void)registerForRoomId:(NSString *)roomId
- completionHandler:(void (^)(ARDRegisterResponse *response,
- NSError *error))completionHandler;
+- (void)joinRoomWithRoomId:(NSString *)roomId
+ completionHandler:(void (^)(ARDJoinResponse *response,
+ NSError *error))completionHandler;
- (void)sendMessage:(ARDSignalingMessage *)message
forRoomId:(NSString *)roomId
@@ -43,7 +43,7 @@
completionHandler:(void (^)(ARDMessageResponse *response,
NSError *error))completionHandler;
-- (void)deregisterForRoomId:(NSString *)roomId
+- (void)leaveRoomWithRoomId:(NSString *)roomId
clientId:(NSString *)clientId
completionHandler:(void (^)(NSError *error))completionHandler;
diff --git a/talk/examples/objc/AppRTCDemo/tests/ARDAppClientTest.mm b/talk/examples/objc/AppRTCDemo/tests/ARDAppClientTest.mm
index 5b76b24..2cdc2d7 100644
--- a/talk/examples/objc/AppRTCDemo/tests/ARDAppClientTest.mm
+++ b/talk/examples/objc/AppRTCDemo/tests/ARDAppClientTest.mm
@@ -30,7 +30,7 @@
#import <OCMock/OCMock.h>
#import "ARDAppClient+Internal.h"
-#import "ARDRegisterResponse+Internal.h"
+#import "ARDJoinResponse+Internal.h"
#import "ARDMessageResponse+Internal.h"
#import "RTCMediaConstraints.h"
#import "RTCPeerConnectionFactory.h"
@@ -136,27 +136,27 @@
id mockRoomServerClient =
[OCMockObject mockForProtocol:@protocol(ARDRoomServerClient)];
- // Successful register response.
- ARDRegisterResponse *registerResponse = [[ARDRegisterResponse alloc] init];
- registerResponse.result = kARDRegisterResultTypeSuccess;
- registerResponse.roomId = roomId;
- registerResponse.clientId = clientId;
- registerResponse.isInitiator = isInitiator;
- registerResponse.messages = messages;
+ // Successful join response.
+ ARDJoinResponse *joinResponse = [[ARDJoinResponse alloc] init];
+ joinResponse.result = kARDJoinResultTypeSuccess;
+ joinResponse.roomId = roomId;
+ joinResponse.clientId = clientId;
+ joinResponse.isInitiator = isInitiator;
+ joinResponse.messages = messages;
// Successful message response.
ARDMessageResponse *messageResponse = [[ARDMessageResponse alloc] init];
messageResponse.result = kARDMessageResultTypeSuccess;
- // Return register response from above on register.
+ // Return join response from above on join.
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
- __unsafe_unretained void (^completionHandler)(ARDRegisterResponse *response,
+ __unsafe_unretained void (^completionHandler)(ARDJoinResponse *response,
NSError *error);
[invocation getArgument:&completionHandler atIndex:3];
- completionHandler(registerResponse, nil);
- }] registerForRoomId:roomId completionHandler:[OCMArg any]];
+ completionHandler(joinResponse, nil);
+ }] joinRoomWithRoomId:roomId completionHandler:[OCMArg any]];
- // Return message response from above on register.
+ // Return message response from above on join.
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
__unsafe_unretained ARDSignalingMessage *message;
__unsafe_unretained void (^completionHandler)(ARDMessageResponse *response,
@@ -170,14 +170,14 @@
clientId:clientId
completionHandler:[OCMArg any]];
- // Do nothing on deregister.
+ // Do nothing on leave.
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
__unsafe_unretained void (^completionHandler)(NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
if (completionHandler) {
completionHandler(nil);
}
- }] deregisterForRoomId:roomId
+ }] leaveRoomWithRoomId:roomId
clientId:clientId
completionHandler:[OCMArg any]];