diff --git a/VideoCalls/NCCallController.m b/VideoCalls/NCCallController.m index b56ef1b4..ce4783b0 100644 --- a/VideoCalls/NCCallController.m +++ b/VideoCalls/NCCallController.m @@ -27,6 +27,7 @@ static NSString * const kNCVideoTrackKind = @"video"; @interface NCCallController () +@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];