Add flag to leave call safely.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2017-10-16 01:28:39 +02:00
Родитель 45c3649a87
Коммит 8cbc36a44a
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -27,6 +27,7 @@ static NSString * const kNCVideoTrackKind = @"video";
@interface NCCallController () <NCPeerConnectionDelegate, NCSignalingControllerObserver>
@property (nonatomic, assign) BOOL leavingCall;
@property (nonatomic, strong) NSTimer *pingTimer;
@property (nonatomic, strong) NSArray *usersInRoom;;
@property (nonatomic, strong) RTCMediaStream *localStream;
@ -75,6 +76,8 @@ static NSString * const kNCVideoTrackKind = @"video";
- (void)leaveCall
{
_leavingCall = YES;
for (NCPeerConnection *peerConnectionWrapper in [_connectionsDict allValues]) {
[peerConnectionWrapper close];
}
@ -243,6 +246,8 @@ static NSString * const kNCVideoTrackKind = @"video";
{
NSString *messageType = [message objectForKey:@"type"];
if (_leavingCall) {return;}
if ([messageType isEqualToString:@"usersInRoom"]) {
[self processUsersInRoom:[message objectForKey:@"data"]];
} else if ([messageType isEqualToString:@"message"]) {
@ -293,6 +298,8 @@ static NSString * const kNCVideoTrackKind = @"video";
// Calculate sessions that join the call
[newSessions removeObjectsInArray:oldSessions];
if (_leavingCall) {return;}
for (NSString *sessionId in newSessions) {
if (![_connectionsDict objectForKey:sessionId]) {
NSComparisonResult result = [sessionId compare:_userSessionId];