Coordinate "busy" state across redphone and webrtc

Previously a redphone call didn't know when the user was busy due to
webrtc and vice versa

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent c4a677a0bc
commit 90388ebd63

@ -405,7 +405,7 @@ protocol CallServiceObserver: class {
Logger.verbose("\(TAG) receivedCallOffer for thread:\(thread)")
let newCall = SignalCall.incomingCall(localId: UUID(), remotePhoneNumber: thread.contactIdentifier(), signalingId: callId)
guard call == nil else {
guard call == nil || Environment.getCurrent().phoneManager.hasOngoingCall() else {
// TODO on iOS10+ we can use CallKit to swap calls rather than just returning busy immediately.
Logger.verbose("\(TAG) receivedCallOffer for thread: \(thread) but we're already in call: \(call)")

@ -6,6 +6,7 @@
#import "CallAudioManager.h"
#import "PhoneManager.h"
#import "RecentCallManager.h"
#import "Signal-Swift.h"
@implementation PhoneManager
@ -92,12 +93,13 @@
int64_t prevSession = lastIncomingSessionId;
lastIncomingSessionId = session.sessionId;
if ([currentCallControllerObservable.currentValue callState].futureTermination.isIncomplete) {
if ([currentCallControllerObservable.currentValue callState].futureTermination.isIncomplete || [self hasOngoingWebRTCCall]) {
if (session.sessionId == prevSession) {
Environment.errorNoter(@"Ignoring duplicate incoming call signal.", session, false);
return;
}
DDLogInfo(@"%@ Missed call due to Busy.", self.tag);
[Environment.getCurrent.recentCallManager addMissedCallDueToBusy:session];
[[CallConnectUtil asyncSignalTooBusyToAnswerCallWithSessionDescriptor:session] catchDo:^(id error) {
@ -146,6 +148,11 @@
return [self.curCallController callState].futureTermination.isIncomplete;
}
- (BOOL)hasOngoingWebRTCCall
{
return !![Environment getCurrent].callService.call;
}
- (CallController *)curCallController {
return currentCallControllerObservable.currentValue;
}
@ -172,4 +179,16 @@
andRelatedInfo:nil];
}
#pragma mark - Logging
+ (NSString *)tag
{
return [NSString stringWithFormat:@"[%@]", self.class];
}
- (NSString *)tag
{
return self.class.tag;
}
@end

Loading…
Cancel
Save