Skip to content

Commit 97993e4

Browse files
authored
Add stop/1 (#15)
1 parent 3773006 commit 97993e4

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ as WebRTC multiplexes traffic on a single socket but PRs are welcomed
2727
```elixir
2828
def deps do
2929
[
30-
{:ex_ice, "~> 0.3.0"}
30+
{:ex_ice, "~> 0.4.0"}
3131
]
3232
end
3333
```

lib/ice_agent.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ defmodule ExICE.ICEAgent do
217217
GenServer.cast(ice_agent, :restart)
218218
end
219219

220+
@doc """
221+
Stops ICE agent and all of its sockets.
222+
"""
223+
@spec stop(pid()) :: :ok
224+
def stop(ice_agent) do
225+
GenServer.stop(ice_agent)
226+
end
227+
220228
### Server
221229

222230
@impl true
@@ -588,6 +596,12 @@ defmodule ExICE.ICEAgent do
588596
{:noreply, state}
589597
end
590598

599+
@impl true
600+
def terminate(reason, _state) do
601+
# we don't need to close sockets manually as this is done automatically by Erlang
602+
Logger.debug("Stopping ICE agent with reason: #{inspect(reason)}")
603+
end
604+
591605
defp do_add_remote_candidate(remote_cand, state) do
592606
local_cands = get_matching_candidates(state.local_cands, remote_cand)
593607

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule ExICE.MixProject do
22
use Mix.Project
33

4-
@version "0.3.0"
4+
@version "0.4.0"
55
@source_url "https://github.com/elixir-webrtc/ex_ice"
66

77
def project do

0 commit comments

Comments
 (0)