зеркало из https://github.com/nextcloud/talk-ios.git
Rejoin room when websocket connection was lost.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
8ae4c0eba9
Коммит
0e994d50c5
|
@ -10,6 +10,7 @@
|
|||
|
||||
#import "SRWebSocket.h"
|
||||
#import "NCAPIController.h"
|
||||
#import "NCRoomsManager.h"
|
||||
#import "NCSettingsController.h"
|
||||
|
||||
static NSTimeInterval kInitialReconnectInterval = 1;
|
||||
|
@ -215,6 +216,11 @@ NSString * const NCESReceivedParticipantListMessageNotification = @"NCESReceived
|
|||
[self sendMessage:message];
|
||||
}
|
||||
_pendingMessages = [NSMutableArray new];
|
||||
|
||||
// Re-join if user was in a room
|
||||
if (_currentRoom && _sessionId) {
|
||||
[[NCRoomsManager sharedInstance] rejoinRoom:_currentRoom];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)errorResponseReceived:(NSDictionary *)errorDict
|
||||
|
@ -242,6 +248,7 @@ NSString * const NCESReceivedParticipantListMessageNotification = @"NCESReceived
|
|||
- (void)leaveRoom:(NSString *)roomId
|
||||
{
|
||||
if ([_currentRoom isEqualToString:roomId]) {
|
||||
_currentRoom = nil;
|
||||
[self joinRoom:@"" withSessionId:@""];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ extern NSString * const NCRoomsManagerDidStartCallNotification;
|
|||
// Room
|
||||
- (void)updateRooms;
|
||||
- (void)updateRoom:(NSString *)token;
|
||||
- (void)rejoinRoom:(NSString *)token;
|
||||
// Chat
|
||||
- (void)startChatInRoom:(NCRoom *)room;
|
||||
- (void)sendChatMessage:(NSString *)message toRoom:(NCRoom *)room;
|
||||
|
|
|
@ -109,6 +109,26 @@ NSString * const NCRoomsManagerDidReceiveChatMessagesNotification = @"ChatMess
|
|||
}
|
||||
}
|
||||
|
||||
- (void)rejoinRoom:(NSString *)token
|
||||
{
|
||||
NCRoomController *roomController = [_activeRooms objectForKey:token];
|
||||
if (roomController) {
|
||||
_joiningRoom = [token copy];
|
||||
_joinRoomTask = [[NCAPIController sharedInstance] joinRoom:token withCompletionBlock:^(NSString *sessionId, NSError *error) {
|
||||
if (!error) {
|
||||
roomController.userSessionId = sessionId;
|
||||
roomController.inChat = YES;
|
||||
if ([[NCExternalSignalingController sharedInstance] isEnabled]) {
|
||||
[[NCExternalSignalingController sharedInstance] joinRoom:token withSessionId:sessionId];
|
||||
}
|
||||
} else {
|
||||
NSLog(@"Could not re-join room. Error: %@", error.description);
|
||||
}
|
||||
_joiningRoom = nil;
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)leaveRoom:(NSString *)token
|
||||
{
|
||||
// Check if leaving the room we are joining
|
||||
|
|
Загрузка…
Ссылка в новой задаче