feat: check new session based off current state
This commit is contained in:
parent
734bb93c48
commit
18884ea06b
|
@ -550,9 +550,10 @@ class WebRtcCallService: Service(), CallManager.WebRtcListener {
|
||||||
handleLocalHangup(intent)
|
handleLocalHangup(intent)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val isNewSession = callManager.currentConnectionState == CallState.Reconnecting
|
||||||
val callId = getCallId(intent)
|
val callId = getCallId(intent)
|
||||||
val description = intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION)
|
val description = intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION)
|
||||||
callManager.handleResponseMessage(recipient, callId, SessionDescription(SessionDescription.Type.ANSWER, description))
|
callManager.handleResponseMessage(recipient, callId, SessionDescription(SessionDescription.Type.ANSWER, description), isNewSession)
|
||||||
} catch (e: PeerConnectionException) {
|
} catch (e: PeerConnectionException) {
|
||||||
terminate()
|
terminate()
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,13 +631,15 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleResponseMessage(recipient: Recipient, callId: UUID, answer: SessionDescription) {
|
fun handleResponseMessage(recipient: Recipient, callId: UUID, answer: SessionDescription, isNewSession: Boolean) {
|
||||||
if (recipient != this.recipient || callId != this.callId) {
|
if (recipient != this.recipient || callId != this.callId) {
|
||||||
Log.w(TAG,"Got answer for recipient and call ID we're not currently dialing")
|
Log.w(TAG,"Got answer for recipient and call ID we're not currently dialing")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stateProcessor.processEvent(Event.ReceiveAnswer) {
|
val event = if (isNewSession) Event.Connect else Event.ReceiveAnswer
|
||||||
|
|
||||||
|
stateProcessor.processEvent(event) {
|
||||||
val connection = peerConnection ?: throw AssertionError("assert")
|
val connection = peerConnection ?: throw AssertionError("assert")
|
||||||
|
|
||||||
connection.setRemoteDescription(answer)
|
connection.setRemoteDescription(answer)
|
||||||
|
|
|
@ -57,7 +57,7 @@ sealed class Event(vararg val expectedStates: State, val outputState: State) {
|
||||||
object Connect : Event(State.Connecting, outputState = State.Connected)
|
object Connect : Event(State.Connecting, outputState = State.Connected)
|
||||||
object IceFailed : Event(State.Connecting, outputState = State.Disconnected)
|
object IceFailed : Event(State.Connecting, outputState = State.Disconnected)
|
||||||
object IceDisconnect : Event(State.Connected, outputState = State.Reconnecting)
|
object IceDisconnect : Event(State.Connected, outputState = State.Reconnecting)
|
||||||
object NetworkReconnect : Event(State.Reconnecting, outputState = State.Connecting)
|
object NetworkReconnect : Event(State.Reconnecting, outputState = State.LocalRing)
|
||||||
object TimeOut :
|
object TimeOut :
|
||||||
Event(State.Connecting, State.LocalRing, State.RemoteRing, outputState = State.Disconnected)
|
Event(State.Connecting, State.LocalRing, State.RemoteRing, outputState = State.Disconnected)
|
||||||
object Error : Event(*State.ALL_STATES, outputState = State.Disconnected)
|
object Error : Event(*State.ALL_STATES, outputState = State.Disconnected)
|
||||||
|
|
Loading…
Reference in New Issue