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
This commit is contained in:
parent
8bb32d600b
commit
36401aba62
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
@property(nonatomic, assign) BOOL isTurnComplete;
|
@property(nonatomic, assign) BOOL isTurnComplete;
|
||||||
@property(nonatomic, assign) BOOL hasReceivedSdp;
|
@property(nonatomic, assign) BOOL hasReceivedSdp;
|
||||||
@property(nonatomic, readonly) BOOL isRegisteredWithRoomServer;
|
@property(nonatomic, readonly) BOOL hasJoinedRoomServerRoom;
|
||||||
|
|
||||||
@property(nonatomic, strong) NSString *roomId;
|
@property(nonatomic, strong) NSString *roomId;
|
||||||
@property(nonatomic, strong) NSString *clientId;
|
@property(nonatomic, strong) NSString *clientId;
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
#import "ARDAppEngineClient.h"
|
#import "ARDAppEngineClient.h"
|
||||||
#import "ARDCEODTURNClient.h"
|
#import "ARDCEODTURNClient.h"
|
||||||
|
#import "ARDJoinResponse.h"
|
||||||
#import "ARDMessageResponse.h"
|
#import "ARDMessageResponse.h"
|
||||||
#import "ARDRegisterResponse.h"
|
|
||||||
#import "ARDSignalingMessage.h"
|
#import "ARDSignalingMessage.h"
|
||||||
#import "ARDUtilities.h"
|
#import "ARDUtilities.h"
|
||||||
#import "ARDWebSocketChannel.h"
|
#import "ARDWebSocketChannel.h"
|
||||||
@ -149,23 +149,23 @@ static NSInteger kARDAppClientErrorInvalidRoom = -6;
|
|||||||
[strongSelf startSignalingIfReady];
|
[strongSelf startSignalingIfReady];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
// Register with room server.
|
// Join room on room server.
|
||||||
[_roomServerClient registerForRoomId:roomId
|
[_roomServerClient joinRoomWithRoomId:roomId
|
||||||
completionHandler:^(ARDRegisterResponse *response, NSError *error) {
|
completionHandler:^(ARDJoinResponse *response, NSError *error) {
|
||||||
ARDAppClient *strongSelf = weakSelf;
|
ARDAppClient *strongSelf = weakSelf;
|
||||||
if (error) {
|
if (error) {
|
||||||
[strongSelf.delegate appClient:strongSelf didError:error];
|
[strongSelf.delegate appClient:strongSelf didError:error];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSError *registerError =
|
NSError *joinError =
|
||||||
[[strongSelf class] errorForRegisterResultType:response.result];
|
[[strongSelf class] errorForJoinResultType:response.result];
|
||||||
if (registerError) {
|
if (joinError) {
|
||||||
NSLog(@"Failed to register with room server.");
|
NSLog(@"Failed to join room:%@ on room server.", roomId);
|
||||||
[strongSelf disconnect];
|
[strongSelf disconnect];
|
||||||
[strongSelf.delegate appClient:strongSelf didError:registerError];
|
[strongSelf.delegate appClient:strongSelf didError:joinError];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSLog(@"Registered with room server.");
|
NSLog(@"Joined room:%@ on room server.", roomId);
|
||||||
strongSelf.roomId = response.roomId;
|
strongSelf.roomId = response.roomId;
|
||||||
strongSelf.clientId = response.clientId;
|
strongSelf.clientId = response.clientId;
|
||||||
strongSelf.isInitiator = response.isInitiator;
|
strongSelf.isInitiator = response.isInitiator;
|
||||||
@ -189,8 +189,8 @@ static NSInteger kARDAppClientErrorInvalidRoom = -6;
|
|||||||
if (_state == kARDAppClientStateDisconnected) {
|
if (_state == kARDAppClientStateDisconnected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self.isRegisteredWithRoomServer) {
|
if (self.hasJoinedRoomServerRoom) {
|
||||||
[_roomServerClient deregisterForRoomId:_roomId
|
[_roomServerClient leaveRoomWithRoomId:_roomId
|
||||||
clientId:_clientId
|
clientId:_clientId
|
||||||
completionHandler:nil];
|
completionHandler:nil];
|
||||||
}
|
}
|
||||||
@ -360,12 +360,12 @@ static NSInteger kARDAppClientErrorInvalidRoom = -6;
|
|||||||
|
|
||||||
#pragma mark - Private
|
#pragma mark - Private
|
||||||
|
|
||||||
- (BOOL)isRegisteredWithRoomServer {
|
- (BOOL)hasJoinedRoomServerRoom {
|
||||||
return _clientId.length;
|
return _clientId.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)startSignalingIfReady {
|
- (void)startSignalingIfReady {
|
||||||
if (!_isTurnComplete || !self.isRegisteredWithRoomServer) {
|
if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.state = kARDAppClientStateConnected;
|
self.state = kARDAppClientStateConnected;
|
||||||
@ -496,7 +496,7 @@ static NSInteger kARDAppClientErrorInvalidRoom = -6;
|
|||||||
#pragma mark - Collider methods
|
#pragma mark - Collider methods
|
||||||
|
|
||||||
- (void)registerWithColliderIfReady {
|
- (void)registerWithColliderIfReady {
|
||||||
if (!self.isRegisteredWithRoomServer) {
|
if (!self.hasJoinedRoomServerRoom) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Open WebSocket connection.
|
// Open WebSocket connection.
|
||||||
@ -558,12 +558,12 @@ static NSInteger kARDAppClientErrorInvalidRoom = -6;
|
|||||||
|
|
||||||
#pragma mark - Errors
|
#pragma mark - Errors
|
||||||
|
|
||||||
+ (NSError *)errorForRegisterResultType:(ARDRegisterResultType)resultType {
|
+ (NSError *)errorForJoinResultType:(ARDJoinResultType)resultType {
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
switch (resultType) {
|
switch (resultType) {
|
||||||
case kARDRegisterResultTypeSuccess:
|
case kARDJoinResultTypeSuccess:
|
||||||
break;
|
break;
|
||||||
case kARDRegisterResultTypeUnknown: {
|
case kARDJoinResultTypeUnknown: {
|
||||||
error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain
|
error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain
|
||||||
code:kARDAppClientErrorUnknown
|
code:kARDAppClientErrorUnknown
|
||||||
userInfo:@{
|
userInfo:@{
|
||||||
@ -571,7 +571,7 @@ static NSInteger kARDAppClientErrorInvalidRoom = -6;
|
|||||||
}];
|
}];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kARDRegisterResultTypeFull: {
|
case kARDJoinResultTypeFull: {
|
||||||
error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain
|
error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain
|
||||||
code:kARDAppClientErrorRoomFull
|
code:kARDAppClientErrorRoomFull
|
||||||
userInfo:@{
|
userInfo:@{
|
||||||
|
@ -27,20 +27,20 @@
|
|||||||
|
|
||||||
#import "ARDAppEngineClient.h"
|
#import "ARDAppEngineClient.h"
|
||||||
|
|
||||||
|
#import "ARDJoinResponse.h"
|
||||||
#import "ARDMessageResponse.h"
|
#import "ARDMessageResponse.h"
|
||||||
#import "ARDRegisterResponse.h"
|
|
||||||
#import "ARDSignalingMessage.h"
|
#import "ARDSignalingMessage.h"
|
||||||
#import "ARDUtilities.h"
|
#import "ARDUtilities.h"
|
||||||
|
|
||||||
// TODO(tkchin): move these to a configuration object.
|
// TODO(tkchin): move these to a configuration object.
|
||||||
static NSString *kARDRoomServerHostUrl =
|
static NSString *kARDRoomServerHostUrl =
|
||||||
@"https://apprtc.appspot.com";
|
@"https://apprtc.appspot.com";
|
||||||
static NSString *kARDRoomServerRegisterFormat =
|
static NSString *kARDRoomServerJoinFormat =
|
||||||
@"https://apprtc.appspot.com/register/%@";
|
@"https://apprtc.appspot.com/join/%@";
|
||||||
static NSString *kARDRoomServerMessageFormat =
|
static NSString *kARDRoomServerMessageFormat =
|
||||||
@"https://apprtc.appspot.com/message/%@/%@";
|
@"https://apprtc.appspot.com/message/%@/%@";
|
||||||
static NSString *kARDRoomServerByeFormat =
|
static NSString *kARDRoomServerLeaveFormat =
|
||||||
@"https://apprtc.appspot.com/bye/%@/%@";
|
@"https://apprtc.appspot.com/leave/%@/%@";
|
||||||
|
|
||||||
static NSString *kARDAppEngineClientErrorDomain = @"ARDAppEngineClient";
|
static NSString *kARDAppEngineClientErrorDomain = @"ARDAppEngineClient";
|
||||||
static NSInteger kARDAppEngineClientErrorBadResponse = -1;
|
static NSInteger kARDAppEngineClientErrorBadResponse = -1;
|
||||||
@ -49,15 +49,15 @@ static NSInteger kARDAppEngineClientErrorBadResponse = -1;
|
|||||||
|
|
||||||
#pragma mark - ARDRoomServerClient
|
#pragma mark - ARDRoomServerClient
|
||||||
|
|
||||||
- (void)registerForRoomId:(NSString *)roomId
|
- (void)joinRoomWithRoomId:(NSString *)roomId
|
||||||
completionHandler:(void (^)(ARDRegisterResponse *response,
|
completionHandler:(void (^)(ARDJoinResponse *response,
|
||||||
NSError *error))completionHandler {
|
NSError *error))completionHandler {
|
||||||
NSParameterAssert(roomId.length);
|
NSParameterAssert(roomId.length);
|
||||||
|
|
||||||
NSString *urlString =
|
NSString *urlString =
|
||||||
[NSString stringWithFormat:kARDRoomServerRegisterFormat, roomId];
|
[NSString stringWithFormat:kARDRoomServerJoinFormat, roomId];
|
||||||
NSURL *roomURL = [NSURL URLWithString:urlString];
|
NSURL *roomURL = [NSURL URLWithString:urlString];
|
||||||
NSLog(@"Registering with room server.");
|
NSLog(@"Joining room:%@ on room server.", roomId);
|
||||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
|
||||||
request.HTTPMethod = @"POST";
|
request.HTTPMethod = @"POST";
|
||||||
__weak ARDAppEngineClient *weakSelf = self;
|
__weak ARDAppEngineClient *weakSelf = self;
|
||||||
@ -72,9 +72,9 @@ static NSInteger kARDAppEngineClientErrorBadResponse = -1;
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ARDRegisterResponse *registerResponse =
|
ARDJoinResponse *joinResponse =
|
||||||
[ARDRegisterResponse responseFromJSONData:data];
|
[ARDJoinResponse responseFromJSONData:data];
|
||||||
if (!registerResponse) {
|
if (!joinResponse) {
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
NSError *error = [[self class] badResponseError];
|
NSError *error = [[self class] badResponseError];
|
||||||
completionHandler(nil, error);
|
completionHandler(nil, error);
|
||||||
@ -82,7 +82,7 @@ static NSInteger kARDAppEngineClientErrorBadResponse = -1;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
completionHandler(registerResponse, nil);
|
completionHandler(joinResponse, nil);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -132,32 +132,33 @@ static NSInteger kARDAppEngineClientErrorBadResponse = -1;
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deregisterForRoomId:(NSString *)roomId
|
- (void)leaveRoomWithRoomId:(NSString *)roomId
|
||||||
clientId:(NSString *)clientId
|
clientId:(NSString *)clientId
|
||||||
completionHandler:(void (^)(NSError *error))completionHandler {
|
completionHandler:(void (^)(NSError *error))completionHandler {
|
||||||
NSParameterAssert(roomId.length);
|
NSParameterAssert(roomId.length);
|
||||||
NSParameterAssert(clientId.length);
|
NSParameterAssert(clientId.length);
|
||||||
|
|
||||||
NSString *urlString =
|
NSString *urlString =
|
||||||
[NSString stringWithFormat:kARDRoomServerByeFormat, roomId, clientId];
|
[NSString stringWithFormat:kARDRoomServerLeaveFormat, roomId, clientId];
|
||||||
NSURL *url = [NSURL URLWithString:urlString];
|
NSURL *url = [NSURL URLWithString:urlString];
|
||||||
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
||||||
NSURLResponse *response = nil;
|
NSURLResponse *response = nil;
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
// We want a synchronous request so that we know that we're unregistered from
|
// We want a synchronous request so that we know that we've left the room on
|
||||||
// room server before we do any further unregistration.
|
// room server before we do any further work.
|
||||||
NSLog(@"C->RS: BYE");
|
NSLog(@"C->RS: BYE");
|
||||||
[NSURLConnection sendSynchronousRequest:request
|
[NSURLConnection sendSynchronousRequest:request
|
||||||
returningResponse:&response
|
returningResponse:&response
|
||||||
error:&error];
|
error:&error];
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Error unregistering from room server: %@", error);
|
NSLog(@"Error leaving room %@ on room server: %@",
|
||||||
|
roomId, error.localizedDescription);
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
completionHandler(error);
|
completionHandler(error);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSLog(@"Unregistered from room server.");
|
NSLog(@"Left room:%@ on room server.", roomId);
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
completionHandler(nil);
|
completionHandler(nil);
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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, assign) BOOL isInitiator;
|
||||||
@property(nonatomic, strong) NSString *roomId;
|
@property(nonatomic, strong) NSString *roomId;
|
||||||
@property(nonatomic, strong) NSString *clientId;
|
@property(nonatomic, strong) NSString *clientId;
|
@ -27,16 +27,16 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, ARDRegisterResultType) {
|
typedef NS_ENUM(NSInteger, ARDJoinResultType) {
|
||||||
kARDRegisterResultTypeUnknown,
|
kARDJoinResultTypeUnknown,
|
||||||
kARDRegisterResultTypeSuccess,
|
kARDJoinResultTypeSuccess,
|
||||||
kARDRegisterResultTypeFull
|
kARDJoinResultTypeFull
|
||||||
};
|
};
|
||||||
|
|
||||||
// Result of registering with the GAE server.
|
// Result of joining a room on the room server.
|
||||||
@interface ARDRegisterResponse : NSObject
|
@interface ARDJoinResponse : NSObject
|
||||||
|
|
||||||
@property(nonatomic, readonly) ARDRegisterResultType result;
|
@property(nonatomic, readonly) ARDJoinResultType result;
|
||||||
@property(nonatomic, readonly) BOOL isInitiator;
|
@property(nonatomic, readonly) BOOL isInitiator;
|
||||||
@property(nonatomic, readonly) NSString *roomId;
|
@property(nonatomic, readonly) NSString *roomId;
|
||||||
@property(nonatomic, readonly) NSString *clientId;
|
@property(nonatomic, readonly) NSString *clientId;
|
||||||
@ -44,6 +44,6 @@ typedef NS_ENUM(NSInteger, ARDRegisterResultType) {
|
|||||||
@property(nonatomic, readonly) NSURL *webSocketURL;
|
@property(nonatomic, readonly) NSURL *webSocketURL;
|
||||||
@property(nonatomic, readonly) NSURL *webSocketRestURL;
|
@property(nonatomic, readonly) NSURL *webSocketRestURL;
|
||||||
|
|
||||||
+ (ARDRegisterResponse *)responseFromJSONData:(NSData *)data;
|
+ (ARDJoinResponse *)responseFromJSONData:(NSData *)data;
|
||||||
|
|
||||||
@end
|
@end
|
@ -25,22 +25,22 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "ARDRegisterResponse+Internal.h"
|
#import "ARDJoinResponse+Internal.h"
|
||||||
|
|
||||||
#import "ARDSignalingMessage.h"
|
#import "ARDSignalingMessage.h"
|
||||||
#import "ARDUtilities.h"
|
#import "ARDUtilities.h"
|
||||||
#import "RTCICEServer+JSON.h"
|
#import "RTCICEServer+JSON.h"
|
||||||
|
|
||||||
static NSString const *kARDRegisterResultKey = @"result";
|
static NSString const *kARDJoinResultKey = @"result";
|
||||||
static NSString const *kARDRegisterResultParamsKey = @"params";
|
static NSString const *kARDJoinResultParamsKey = @"params";
|
||||||
static NSString const *kARDRegisterInitiatorKey = @"is_initiator";
|
static NSString const *kARDJoinInitiatorKey = @"is_initiator";
|
||||||
static NSString const *kARDRegisterRoomIdKey = @"room_id";
|
static NSString const *kARDJoinRoomIdKey = @"room_id";
|
||||||
static NSString const *kARDRegisterClientIdKey = @"client_id";
|
static NSString const *kARDJoinClientIdKey = @"client_id";
|
||||||
static NSString const *kARDRegisterMessagesKey = @"messages";
|
static NSString const *kARDJoinMessagesKey = @"messages";
|
||||||
static NSString const *kARDRegisterWebSocketURLKey = @"wss_url";
|
static NSString const *kARDJoinWebSocketURLKey = @"wss_url";
|
||||||
static NSString const *kARDRegisterWebSocketRestURLKey = @"wss_post_url";
|
static NSString const *kARDJoinWebSocketRestURLKey = @"wss_post_url";
|
||||||
|
|
||||||
@implementation ARDRegisterResponse
|
@implementation ARDJoinResponse
|
||||||
|
|
||||||
@synthesize result = _result;
|
@synthesize result = _result;
|
||||||
@synthesize isInitiator = _isInitiator;
|
@synthesize isInitiator = _isInitiator;
|
||||||
@ -50,22 +50,22 @@ static NSString const *kARDRegisterWebSocketRestURLKey = @"wss_post_url";
|
|||||||
@synthesize webSocketURL = _webSocketURL;
|
@synthesize webSocketURL = _webSocketURL;
|
||||||
@synthesize webSocketRestURL = _webSocketRestURL;
|
@synthesize webSocketRestURL = _webSocketRestURL;
|
||||||
|
|
||||||
+ (ARDRegisterResponse *)responseFromJSONData:(NSData *)data {
|
+ (ARDJoinResponse *)responseFromJSONData:(NSData *)data {
|
||||||
NSDictionary *responseJSON = [NSDictionary dictionaryWithJSONData:data];
|
NSDictionary *responseJSON = [NSDictionary dictionaryWithJSONData:data];
|
||||||
if (!responseJSON) {
|
if (!responseJSON) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
ARDRegisterResponse *response = [[ARDRegisterResponse alloc] init];
|
ARDJoinResponse *response = [[ARDJoinResponse alloc] init];
|
||||||
NSString *resultString = responseJSON[kARDRegisterResultKey];
|
NSString *resultString = responseJSON[kARDJoinResultKey];
|
||||||
response.result = [[self class] resultTypeFromString:resultString];
|
response.result = [[self class] resultTypeFromString:resultString];
|
||||||
NSDictionary *params = responseJSON[kARDRegisterResultParamsKey];
|
NSDictionary *params = responseJSON[kARDJoinResultParamsKey];
|
||||||
|
|
||||||
response.isInitiator = [params[kARDRegisterInitiatorKey] boolValue];
|
response.isInitiator = [params[kARDJoinInitiatorKey] boolValue];
|
||||||
response.roomId = params[kARDRegisterRoomIdKey];
|
response.roomId = params[kARDJoinRoomIdKey];
|
||||||
response.clientId = params[kARDRegisterClientIdKey];
|
response.clientId = params[kARDJoinClientIdKey];
|
||||||
|
|
||||||
// Parse messages.
|
// Parse messages.
|
||||||
NSArray *messages = params[kARDRegisterMessagesKey];
|
NSArray *messages = params[kARDJoinMessagesKey];
|
||||||
NSMutableArray *signalingMessages =
|
NSMutableArray *signalingMessages =
|
||||||
[NSMutableArray arrayWithCapacity:messages.count];
|
[NSMutableArray arrayWithCapacity:messages.count];
|
||||||
for (NSString *message in messages) {
|
for (NSString *message in messages) {
|
||||||
@ -76,9 +76,9 @@ static NSString const *kARDRegisterWebSocketRestURLKey = @"wss_post_url";
|
|||||||
response.messages = signalingMessages;
|
response.messages = signalingMessages;
|
||||||
|
|
||||||
// Parse websocket urls.
|
// Parse websocket urls.
|
||||||
NSString *webSocketURLString = params[kARDRegisterWebSocketURLKey];
|
NSString *webSocketURLString = params[kARDJoinWebSocketURLKey];
|
||||||
response.webSocketURL = [NSURL URLWithString:webSocketURLString];
|
response.webSocketURL = [NSURL URLWithString:webSocketURLString];
|
||||||
NSString *webSocketRestURLString = params[kARDRegisterWebSocketRestURLKey];
|
NSString *webSocketRestURLString = params[kARDJoinWebSocketRestURLKey];
|
||||||
response.webSocketRestURL = [NSURL URLWithString:webSocketRestURLString];
|
response.webSocketRestURL = [NSURL URLWithString:webSocketRestURLString];
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@ -86,12 +86,12 @@ static NSString const *kARDRegisterWebSocketRestURLKey = @"wss_post_url";
|
|||||||
|
|
||||||
#pragma mark - Private
|
#pragma mark - Private
|
||||||
|
|
||||||
+ (ARDRegisterResultType)resultTypeFromString:(NSString *)resultString {
|
+ (ARDJoinResultType)resultTypeFromString:(NSString *)resultString {
|
||||||
ARDRegisterResultType result = kARDRegisterResultTypeUnknown;
|
ARDJoinResultType result = kARDJoinResultTypeUnknown;
|
||||||
if ([resultString isEqualToString:@"SUCCESS"]) {
|
if ([resultString isEqualToString:@"SUCCESS"]) {
|
||||||
result = kARDRegisterResultTypeSuccess;
|
result = kARDJoinResultTypeSuccess;
|
||||||
} else if ([resultString isEqualToString:@"FULL"]) {
|
} else if ([resultString isEqualToString:@"FULL"]) {
|
||||||
result = kARDRegisterResultTypeFull;
|
result = kARDJoinResultTypeFull;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
@ -27,15 +27,15 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@class ARDJoinResponse;
|
||||||
@class ARDMessageResponse;
|
@class ARDMessageResponse;
|
||||||
@class ARDRegisterResponse;
|
|
||||||
@class ARDSignalingMessage;
|
@class ARDSignalingMessage;
|
||||||
|
|
||||||
@protocol ARDRoomServerClient <NSObject>
|
@protocol ARDRoomServerClient <NSObject>
|
||||||
|
|
||||||
- (void)registerForRoomId:(NSString *)roomId
|
- (void)joinRoomWithRoomId:(NSString *)roomId
|
||||||
completionHandler:(void (^)(ARDRegisterResponse *response,
|
completionHandler:(void (^)(ARDJoinResponse *response,
|
||||||
NSError *error))completionHandler;
|
NSError *error))completionHandler;
|
||||||
|
|
||||||
- (void)sendMessage:(ARDSignalingMessage *)message
|
- (void)sendMessage:(ARDSignalingMessage *)message
|
||||||
forRoomId:(NSString *)roomId
|
forRoomId:(NSString *)roomId
|
||||||
@ -43,7 +43,7 @@
|
|||||||
completionHandler:(void (^)(ARDMessageResponse *response,
|
completionHandler:(void (^)(ARDMessageResponse *response,
|
||||||
NSError *error))completionHandler;
|
NSError *error))completionHandler;
|
||||||
|
|
||||||
- (void)deregisterForRoomId:(NSString *)roomId
|
- (void)leaveRoomWithRoomId:(NSString *)roomId
|
||||||
clientId:(NSString *)clientId
|
clientId:(NSString *)clientId
|
||||||
completionHandler:(void (^)(NSError *error))completionHandler;
|
completionHandler:(void (^)(NSError *error))completionHandler;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#import <OCMock/OCMock.h>
|
#import <OCMock/OCMock.h>
|
||||||
|
|
||||||
#import "ARDAppClient+Internal.h"
|
#import "ARDAppClient+Internal.h"
|
||||||
#import "ARDRegisterResponse+Internal.h"
|
#import "ARDJoinResponse+Internal.h"
|
||||||
#import "ARDMessageResponse+Internal.h"
|
#import "ARDMessageResponse+Internal.h"
|
||||||
#import "RTCMediaConstraints.h"
|
#import "RTCMediaConstraints.h"
|
||||||
#import "RTCPeerConnectionFactory.h"
|
#import "RTCPeerConnectionFactory.h"
|
||||||
@ -136,27 +136,27 @@
|
|||||||
id mockRoomServerClient =
|
id mockRoomServerClient =
|
||||||
[OCMockObject mockForProtocol:@protocol(ARDRoomServerClient)];
|
[OCMockObject mockForProtocol:@protocol(ARDRoomServerClient)];
|
||||||
|
|
||||||
// Successful register response.
|
// Successful join response.
|
||||||
ARDRegisterResponse *registerResponse = [[ARDRegisterResponse alloc] init];
|
ARDJoinResponse *joinResponse = [[ARDJoinResponse alloc] init];
|
||||||
registerResponse.result = kARDRegisterResultTypeSuccess;
|
joinResponse.result = kARDJoinResultTypeSuccess;
|
||||||
registerResponse.roomId = roomId;
|
joinResponse.roomId = roomId;
|
||||||
registerResponse.clientId = clientId;
|
joinResponse.clientId = clientId;
|
||||||
registerResponse.isInitiator = isInitiator;
|
joinResponse.isInitiator = isInitiator;
|
||||||
registerResponse.messages = messages;
|
joinResponse.messages = messages;
|
||||||
|
|
||||||
// Successful message response.
|
// Successful message response.
|
||||||
ARDMessageResponse *messageResponse = [[ARDMessageResponse alloc] init];
|
ARDMessageResponse *messageResponse = [[ARDMessageResponse alloc] init];
|
||||||
messageResponse.result = kARDMessageResultTypeSuccess;
|
messageResponse.result = kARDMessageResultTypeSuccess;
|
||||||
|
|
||||||
// Return register response from above on register.
|
// Return join response from above on join.
|
||||||
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
||||||
__unsafe_unretained void (^completionHandler)(ARDRegisterResponse *response,
|
__unsafe_unretained void (^completionHandler)(ARDJoinResponse *response,
|
||||||
NSError *error);
|
NSError *error);
|
||||||
[invocation getArgument:&completionHandler atIndex:3];
|
[invocation getArgument:&completionHandler atIndex:3];
|
||||||
completionHandler(registerResponse, nil);
|
completionHandler(joinResponse, nil);
|
||||||
}] registerForRoomId:roomId completionHandler:[OCMArg any]];
|
}] joinRoomWithRoomId:roomId completionHandler:[OCMArg any]];
|
||||||
|
|
||||||
// Return message response from above on register.
|
// Return message response from above on join.
|
||||||
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
||||||
__unsafe_unretained ARDSignalingMessage *message;
|
__unsafe_unretained ARDSignalingMessage *message;
|
||||||
__unsafe_unretained void (^completionHandler)(ARDMessageResponse *response,
|
__unsafe_unretained void (^completionHandler)(ARDMessageResponse *response,
|
||||||
@ -170,14 +170,14 @@
|
|||||||
clientId:clientId
|
clientId:clientId
|
||||||
completionHandler:[OCMArg any]];
|
completionHandler:[OCMArg any]];
|
||||||
|
|
||||||
// Do nothing on deregister.
|
// Do nothing on leave.
|
||||||
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
[[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) {
|
||||||
__unsafe_unretained void (^completionHandler)(NSError *error);
|
__unsafe_unretained void (^completionHandler)(NSError *error);
|
||||||
[invocation getArgument:&completionHandler atIndex:4];
|
[invocation getArgument:&completionHandler atIndex:4];
|
||||||
if (completionHandler) {
|
if (completionHandler) {
|
||||||
completionHandler(nil);
|
completionHandler(nil);
|
||||||
}
|
}
|
||||||
}] deregisterForRoomId:roomId
|
}] leaveRoomWithRoomId:roomId
|
||||||
clientId:clientId
|
clientId:clientId
|
||||||
completionHandler:[OCMArg any]];
|
completionHandler:[OCMArg any]];
|
||||||
|
|
||||||
|
@ -161,12 +161,12 @@
|
|||||||
'examples/objc/AppRTCDemo/ARDAppEngineClient.m',
|
'examples/objc/AppRTCDemo/ARDAppEngineClient.m',
|
||||||
'examples/objc/AppRTCDemo/ARDCEODTURNClient.h',
|
'examples/objc/AppRTCDemo/ARDCEODTURNClient.h',
|
||||||
'examples/objc/AppRTCDemo/ARDCEODTURNClient.m',
|
'examples/objc/AppRTCDemo/ARDCEODTURNClient.m',
|
||||||
|
'examples/objc/AppRTCDemo/ARDJoinResponse.h',
|
||||||
|
'examples/objc/AppRTCDemo/ARDJoinResponse.m',
|
||||||
|
'examples/objc/AppRTCDemo/ARDJoinResponse+Internal.h',
|
||||||
'examples/objc/AppRTCDemo/ARDMessageResponse.h',
|
'examples/objc/AppRTCDemo/ARDMessageResponse.h',
|
||||||
'examples/objc/AppRTCDemo/ARDMessageResponse.m',
|
'examples/objc/AppRTCDemo/ARDMessageResponse.m',
|
||||||
'examples/objc/AppRTCDemo/ARDMessageResponse+Internal.h',
|
'examples/objc/AppRTCDemo/ARDMessageResponse+Internal.h',
|
||||||
'examples/objc/AppRTCDemo/ARDRegisterResponse.h',
|
|
||||||
'examples/objc/AppRTCDemo/ARDRegisterResponse.m',
|
|
||||||
'examples/objc/AppRTCDemo/ARDRegisterResponse+Internal.h',
|
|
||||||
'examples/objc/AppRTCDemo/ARDRoomServerClient.h',
|
'examples/objc/AppRTCDemo/ARDRoomServerClient.h',
|
||||||
'examples/objc/AppRTCDemo/ARDSignalingChannel.h',
|
'examples/objc/AppRTCDemo/ARDSignalingChannel.h',
|
||||||
'examples/objc/AppRTCDemo/ARDSignalingMessage.h',
|
'examples/objc/AppRTCDemo/ARDSignalingMessage.h',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user