Skip to content

Commit

Permalink
Add maximum active calls configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
artemkrachulov committed Sep 28, 2023
1 parent a4860b0 commit 1911a71
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MatrixSDK/VoIP/CallKit/MXCallKitAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ API_AVAILABLE(ios(10.0))
*/
+ (BOOL)callKitAvailable;

/**
The maximum number of calls.
Defaults is -1. Any count
*/
@property (nonatomic) NSUInteger maximumActiveCalls;


@end

NS_ASSUME_NONNULL_END
Expand Down
2 changes: 2 additions & 0 deletions MatrixSDK/VoIP/CallKit/MXCallKitAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ - (instancetype)initWithConfiguration:(MXCallKitConfiguration *)configuration
_callController = [[CXCallController alloc] initWithQueue:dispatch_get_main_queue()];

_calls = [NSMutableDictionary dictionary];

_maximumActiveCalls = -1;
}

return self;
Expand Down
8 changes: 8 additions & 0 deletions MatrixSDK/VoIP/MXCallManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,14 @@ - (void)handleCallInvite:(MXEvent *)event
call = [[MXCall alloc] initWithRoomId:nativeRoomId callSignalingRoomId:event.roomId andCallManager:self];
if (call)
{

if (_callKitAdapter.maximumActiveCalls != -1 && calls.count >= _callKitAdapter.maximumActiveCalls) {

[call hangupWithReason: MXCallHangupReasonUserBusy];

return;
}

[calls addObject:call];

[call handleCallEvent:event];
Expand Down

0 comments on commit 1911a71

Please sign in to comment.