Skip to content

Commit b240306

Browse files
authored
Accept padded DataChannelAck, fix closing DataChannel (#207)
1 parent 26f929d commit b240306

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/ex_webrtc/sctp_transport.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ if Code.ensure_loaded?(ExSCTP) do
279279

280280
ExSCTP.close_stream(sctp_transport.ref, id)
281281

282-
case Enum.find_value(sctp_transport.channels, fn {_k, v} -> v.id == id end) do
282+
case Enum.find(sctp_transport.channels, fn {_k, v} -> v.id == id end) do
283283
{ref, %DataChannel{}} ->
284284
channels = Map.delete(sctp_transport.channels, ref)
285285
stats = Map.delete(sctp_transport.stats, ref)

lib/ex_webrtc/sctp_transport/dcep.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule ExWebRTC.SCTPTransport.DCEP do
88
defstruct []
99

1010
def decode(<<>>), do: {:ok, %__MODULE__{}}
11+
# Some implementations (e.g. Pion) seems to pad DataChannelAck to 4 bytes. Accept them.
12+
def decode(<<_, _, _>>), do: {:ok, %__MODULE__{}}
1113
def decode(_other), do: :error
1214

1315
def encode(%__MODULE__{}), do: <<0x02>>

0 commit comments

Comments
 (0)