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)
|
||||
return
|
||||
}
|
||||
val isNewSession = callManager.currentConnectionState == CallState.Reconnecting
|
||||
val callId = getCallId(intent)
|
||||
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) {
|
||||
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) {
|
||||
Log.w(TAG,"Got answer for recipient and call ID we're not currently dialing")
|
||||
return
|
||||
}
|
||||
|
||||
stateProcessor.processEvent(Event.ReceiveAnswer) {
|
||||
val event = if (isNewSession) Event.Connect else Event.ReceiveAnswer
|
||||
|
||||
stateProcessor.processEvent(event) {
|
||||
val connection = peerConnection ?: throw AssertionError("assert")
|
||||
|
||||
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 IceFailed : Event(State.Connecting, outputState = State.Disconnected)
|
||||
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 :
|
||||
Event(State.Connecting, State.LocalRing, State.RemoteRing, outputState = State.Disconnected)
|
||||
object Error : Event(*State.ALL_STATES, outputState = State.Disconnected)
|
||||
|
|
Loading…
Reference in New Issue