Skip to content

Commit

Permalink
Refactor next_conn_state
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Nov 27, 2023
1 parent 0cbf5a1 commit a86f6ab
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/ex_webrtc/peer_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,18 @@ defmodule ExWebRTC.PeerConnection do
defp next_conn_state(ice_state, dtls_state) when ice_state == :failed or dtls_state == :failed,
do: :failed

defp next_conn_state(ice_state, dtls_state) when ice_state == :new and dtls_state == :new,
do: :new
defp next_conn_state(:failed, _dtls_state), do: :failed

defp next_conn_state(_ice_state, :failed), do: :failed

defp next_conn_state(:new, :new), do: :new

defp next_conn_state(ice_state, dtls_state)
when ice_state in [:new, :checking] or dtls_state in [:new, :connecting],
do: :connecting

defp next_conn_state(ice_state, dtls_state)
when ice_state in [:connected, :completed] and dtls_state in [:connected],
do: :connected
defp next_conn_state(ice_state, :connected) when ice_state in [:connected, :completed],
do: :connected

defp update_conn_state(%{conn_state: conn_state} = state, conn_state), do: state

Expand Down

0 comments on commit a86f6ab

Please sign in to comment.