@@ -65,7 +65,7 @@ defmodule ExICE.Priv.ICEAgent do
6565 eoc: false ,
6666 # {did we nominate pair, pair id}
6767 nominating?: { false , nil } ,
68- sockets: MapSet . new ( ) ,
68+ sockets: [ ] ,
6969 local_cands: % { } ,
7070 remote_cands: % { } ,
7171 stun_servers: [ ] ,
@@ -213,9 +213,7 @@ defmodule ExICE.Priv.ICEAgent do
213213 def gather_candidates (
214214 % __MODULE__ { gathering_state: :new , ice_transport_policy: :all } = ice_agent
215215 ) do
216- Logger . debug ( "Gathering state change: #{ ice_agent . gathering_state } -> gathering" )
217- notify ( ice_agent . on_gathering_state_change , { :gathering_state_change , :gathering } )
218- ice_agent = % { ice_agent | gathering_state: :gathering }
216+ ice_agent = change_gathering_state ( ice_agent , :gathering )
219217
220218 { :ok , sockets } = Gatherer . open_sockets ( ice_agent . gatherer )
221219 host_cands = Gatherer . gather_host_candidates ( ice_agent . gatherer , sockets )
@@ -247,7 +245,7 @@ defmodule ExICE.Priv.ICEAgent do
247245 def gather_candidates (
248246 % __MODULE__ { gathering_state: :new , ice_transport_policy: :relay } = ice_agent
249247 ) do
250- change_gathering_state ( ice_agent , :gathering )
248+ ice_agent = change_gathering_state ( ice_agent , :gathering )
251249
252250 { :ok , sockets } = Gatherer . open_sockets ( ice_agent . gatherer )
253251
@@ -734,6 +732,10 @@ defmodule ExICE.Priv.ICEAgent do
734732 { _socket , { src_ip , src_port } } = tr_id
735733
736734 case ExTURN.Client . handle_message ( tr . client , { :socket_data , src_ip , src_port , packet } ) do
735+ { :ok , client } ->
736+ tr = % { tr | client: client }
737+ put_in ( ice_agent . gathering_transactions [ tr_id ] , tr )
738+
737739 { :allocation_created , { alloc_ip , alloc_port } , client } ->
738740 tr = % { tr | client: client , state: :complete }
739741
@@ -1921,14 +1923,16 @@ defmodule ExICE.Priv.ICEAgent do
19211923
19221924 defp send_keepalive ( ice_agent , pair ) do
19231925 type = % Type { class: :indication , method: :binding }
1926+ local_cand = Map . fetch! ( ice_agent . local_cands , pair . local_cand_id )
1927+ remote_cand = Map . fetch! ( ice_agent . remote_cands , pair . remote_cand_id )
19241928
19251929 req =
19261930 type
19271931 |> Message . new ( )
19281932 |> Message . with_fingerprint ( )
19291933
1930- dst = { pair . remote_cand . address , pair . remote_cand . port }
1931- { _result , ice_agent } = do_send ( ice_agent , pair . local_cand , dst , Message . encode ( req ) )
1934+ dst = { remote_cand . address , remote_cand . port }
1935+ { _result , ice_agent } = do_send ( ice_agent , local_cand , dst , Message . encode ( req ) )
19321936 ice_agent
19331937 end
19341938
0 commit comments