@@ -245,9 +245,9 @@ defmodule ExWebRTC.PeerConnection do
245245
246246 If `ref` does not identify any DataChannel, this function behaves like no-op.
247247 """
248- @ spec send_data ( peer_connection ( ) , DataChannel . ref ( ) , binary ( ) ) :: :ok
249- def send_data ( peer_connection , channel_ref , data ) do
250- GenServer . cast ( peer_connection , { :send_data , channel_ref , data } )
248+ @ spec send_data ( peer_connection ( ) , DataChannel . ref ( ) , binary ( ) , :string | :binary ) :: :ok
249+ def send_data ( peer_connection , channel_ref , data , data_type \\ :string ) do
250+ GenServer . cast ( peer_connection , { :send_data , channel_ref , data_type , data } )
251251 end
252252
253253 @ doc """
@@ -1265,10 +1265,9 @@ defmodule ExWebRTC.PeerConnection do
12651265 end
12661266
12671267 @ impl true
1268- def handle_cast ( { :send_data , channel_ref , data } , state ) do
1269- # TODO: allow for configuring the type of data
1268+ def handle_cast ( { :send_data , channel_ref , data_type , data } , state ) do
12701269 { events , sctp_transport } =
1271- SCTPTransport . send ( state . sctp_transport , channel_ref , :string , data )
1270+ SCTPTransport . send ( state . sctp_transport , channel_ref , data_type , data )
12721271
12731272 handle_sctp_events ( events , state )
12741273
0 commit comments