From a86f6ab79463653760cda3770297020c86230c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=9Aled=C5=BA?= Date: Mon, 27 Nov 2023 10:50:26 +0100 Subject: [PATCH] Refactor next_conn_state --- lib/ex_webrtc/peer_connection.ex | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ex_webrtc/peer_connection.ex b/lib/ex_webrtc/peer_connection.ex index e20044c1..73fbacd5 100644 --- a/lib/ex_webrtc/peer_connection.ex +++ b/lib/ex_webrtc/peer_connection.ex @@ -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