Fix call invite processed after call is ended because of fastlane mode.
This commit is contained in:
parent
ca3e5cdf90
commit
a2c8680d7a
|
@ -0,0 +1 @@
|
||||||
|
Fix call invite processed after call is ended because of fastlane mode.
|
|
@ -59,9 +59,8 @@ internal class CallEventProcessor @Inject constructor(private val callSignalingH
|
||||||
return eventType == EventType.CALL_INVITE
|
return eventType == EventType.CALL_INVITE
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun processFastLane(event: Event) {
|
fun processFastLane(event: Event) {
|
||||||
eventsToPostProcess.add(event)
|
dispatchToCallSignalingHandlerIfNeeded(event)
|
||||||
onPostProcess()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun onPostProcess() {
|
override suspend fun onPostProcess() {
|
||||||
|
@ -73,13 +72,12 @@ internal class CallEventProcessor @Inject constructor(private val callSignalingH
|
||||||
|
|
||||||
private fun dispatchToCallSignalingHandlerIfNeeded(event: Event) {
|
private fun dispatchToCallSignalingHandlerIfNeeded(event: Event) {
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
// TODO might check if an invite is not closed (hangup/answered) in the same event batch?
|
|
||||||
event.roomId ?: return Unit.also {
|
event.roomId ?: return Unit.also {
|
||||||
Timber.w("Event with no room id ${event.eventId}")
|
Timber.w("Event with no room id ${event.eventId}")
|
||||||
}
|
}
|
||||||
val age = now - (event.ageLocalTs ?: now)
|
val age = now - (event.ageLocalTs ?: now)
|
||||||
if (age > 40_000) {
|
if (age > 40_000) {
|
||||||
// To old to ring?
|
// Too old to ring?
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
callSignalingHandler.onCallEvent(event)
|
callSignalingHandler.onCallEvent(event)
|
||||||
|
|
|
@ -41,6 +41,7 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa
|
||||||
private val mxCallFactory: MxCallFactory,
|
private val mxCallFactory: MxCallFactory,
|
||||||
@UserId private val userId: String) {
|
@UserId private val userId: String) {
|
||||||
|
|
||||||
|
private val invitedCallIds = mutableSetOf<String>()
|
||||||
private val callListeners = mutableSetOf<CallListener>()
|
private val callListeners = mutableSetOf<CallListener>()
|
||||||
private val callListenersDispatcher = CallListenersDispatcher(callListeners)
|
private val callListenersDispatcher = CallListenersDispatcher(callListeners)
|
||||||
|
|
||||||
|
@ -182,17 +183,17 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa
|
||||||
val content = event.getClearContent().toModel<CallInviteContent>() ?: return
|
val content = event.getClearContent().toModel<CallInviteContent>() ?: return
|
||||||
|
|
||||||
content.callId ?: return
|
content.callId ?: return
|
||||||
if (activeCallHandler.getCallWithId(content.callId) != null) {
|
if (invitedCallIds.contains(content.callId)) {
|
||||||
// Call is already known, maybe due to fast lane. Ignore
|
// Call is already known, maybe due to fast lane. Ignore
|
||||||
Timber.d("Ignoring already known call invite")
|
Timber.d("Ignoring already known call invite")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val incomingCall = mxCallFactory.createIncomingCall(
|
val incomingCall = mxCallFactory.createIncomingCall(
|
||||||
roomId = event.roomId,
|
roomId = event.roomId,
|
||||||
opponentUserId = event.senderId,
|
opponentUserId = event.senderId,
|
||||||
content = content
|
content = content
|
||||||
) ?: return
|
) ?: return
|
||||||
|
invitedCallIds.add(content.callId)
|
||||||
activeCallHandler.addCall(incomingCall)
|
activeCallHandler.addCall(incomingCall)
|
||||||
callListenersDispatcher.onCallInviteReceived(incomingCall, content)
|
callListenersDispatcher.onCallInviteReceived(incomingCall, content)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ internal class DefaultEventService @Inject constructor(
|
||||||
|
|
||||||
override suspend fun getEvent(roomId: String, eventId: String): Event {
|
override suspend fun getEvent(roomId: String, eventId: String): Event {
|
||||||
val event = getEventTask.execute(GetEventTask.Params(roomId, eventId))
|
val event = getEventTask.execute(GetEventTask.Params(roomId, eventId))
|
||||||
|
event.ageLocalTs = event.unsignedData?.age?.let { System.currentTimeMillis() - it }
|
||||||
// Fast lane to the call event processors: try to make the incoming call ring faster
|
// Fast lane to the call event processors: try to make the incoming call ring faster
|
||||||
if (callEventProcessor.shouldProcessFastLane(event.getClearType())) {
|
if (callEventProcessor.shouldProcessFastLane(event.getClearType())) {
|
||||||
callEventProcessor.processFastLane(event)
|
callEventProcessor.processFastLane(event)
|
||||||
|
|
Loading…
Reference in New Issue