Transfering files via an RTCDataChannel connection
The model here is the same as interacting with signaling_server
, except in this case the data is flowing directly to the other peer instead via the WebSocket server.
To send some data you simply call the data_channel.send()
function just as you call the signaling_server.send()
function.
And to handle receiving the data you set up a data_channel.onmessage
handler, just like you set up the signaling_server.onmessage
handler.
In this way, the core usage of the two API's is almost identical. It is only the underlying network implementation that really differs.