Skip to content

Commit 57a453d

Browse files
committed
Wrap connection state change message into a tuple
1 parent 99d4e94 commit 57a453d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/ice_agent.ex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,23 @@ defmodule ExICE.ICEAgent do
4444
4545
For exact meaning refer to the W3C WebRTC standard, sec 5.6.3.
4646
"""
47-
@type gathering_state_changed() :: {:gathering_state_change, :new | :gathering | :complete}
47+
@type gathering_state_change() :: {:gathering_state_change, :new | :gathering | :complete}
4848

4949
@typedoc """
5050
Emitted when connection state has changed.
5151
5252
For exact meaning refer to the W3C WebRTC standard, sec. 5.6.4.
5353
"""
54-
@type connection_state_changed() :: :checking | :connected | :completed | :failed
54+
@type connection_state_change() ::
55+
{:connection_state_change, :checking | :connected | :completed | :failed}
5556

5657
@typedoc """
5758
Messages sent by the ExICE.
5859
"""
5960
@type signal() ::
6061
{:ex_ice, pid(),
61-
gathering_state_changed()
62-
| connection_state_changed
62+
gathering_state_change()
63+
| connection_state_change()
6364
| {:data, binary()}
6465
| {:new_candidate, binary()}}
6566

@@ -1403,7 +1404,7 @@ defmodule ExICE.ICEAgent do
14031404
@spec change_connection_state(atom(), map()) :: map()
14041405
def change_connection_state(new_conn_state, state) do
14051406
Logger.debug("Connection state change: #{state.state} -> #{new_conn_state}")
1406-
send(state.controlling_process, {:ex_ice, self(), new_conn_state})
1407+
send(state.controlling_process, {:ex_ice, self(), {:connection_state_change, new_conn_state}})
14071408
%{state | state: new_conn_state}
14081409
end
14091410

test/integration/p2p_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ defmodule ExICE.Integration.P2PTest do
131131
ICEAgent.end_of_candidates(agent2)
132132
p2p(agent1, agent2, a1_status, a2_status)
133133

134-
{:ex_ice, ^agent1, :connected} ->
134+
{:ex_ice, ^agent1, {:connection_state_change, :connected}} ->
135135
Logger.info("Connected, sending file...")
136136

137137
Task.start(fn ->
@@ -151,7 +151,7 @@ defmodule ExICE.Integration.P2PTest do
151151
:ok = IO.binwrite(a1_status.fd, data)
152152
p2p(agent1, agent2, a1_status, a2_status)
153153

154-
{:ex_ice, ^agent1, :completed} ->
154+
{:ex_ice, ^agent1, {:connection_state_change, :completed}} ->
155155
Logger.info("Completed")
156156
a1_status = %{a1_status | completed: true}
157157
p2p(agent1, agent2, a1_status, a2_status)
@@ -164,12 +164,12 @@ defmodule ExICE.Integration.P2PTest do
164164
ICEAgent.end_of_candidates(agent1)
165165
p2p(agent1, agent2, a1_status, a2_status)
166166

167-
{:ex_ice, ^agent2, :completed} ->
167+
{:ex_ice, ^agent2, {:connection_state_change, :completed}} ->
168168
Logger.info("Completed")
169169
a2_status = %{a2_status | completed: true}
170170
p2p(agent1, agent2, a1_status, a2_status)
171171

172-
{:ex_ice, ^agent2, :connected} ->
172+
{:ex_ice, ^agent2, {:connection_state_change, :connected}} ->
173173
Logger.info("Connected, sending file...")
174174

175175
Task.start(fn ->

0 commit comments

Comments
 (0)