@@ -245,9 +245,9 @@ defmodule ExWebRTC.PeerConnection do
245
245
246
246
If `ref` does not identify any DataChannel, this function behaves like no-op.
247
247
"""
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 } )
251
251
end
252
252
253
253
@ doc """
@@ -1265,10 +1265,9 @@ defmodule ExWebRTC.PeerConnection do
1265
1265
end
1266
1266
1267
1267
@ 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
1270
1269
{ events , sctp_transport } =
1271
- SCTPTransport . send ( state . sctp_transport , channel_ref , :string , data )
1270
+ SCTPTransport . send ( state . sctp_transport , channel_ref , data_type , data )
1272
1271
1273
1272
handle_sctp_events ( events , state )
1274
1273
0 commit comments