I was excited by the prospect of WebRTC when I heard about it initially. It sounded like websockets but without a server. Unfortunately, all of the tutorials I have been a
This is an old question, but because I started to learn webRTC, I will attempt to answer it.
First of all, some misconception:
It sounded like websockets but without a server
There is no way ANY data can be transferred between WebRTC peers before some information (Media session management, Nodes’ network configuration/multimedia capabilities) has been properly exchanged and negotiated. To do this you need a server and signalling (which is not a part of webRTC: you can implement it the way you want).
When the signaling is done, you need to create RTCPeerConnection with something like this:
if (navigator.webkitGetUserMedia) {
RTCPeerConnection = webkitRTCPeerConnection;
} else if(navigator.mozGetUserMedia){
RTCPeerConnection = mozRTCPeerConnection;
RTCSessionDescription = mozRTCSessionDescription;
RTCIceCandidate = mozRTCIceCandidate;
}
and then:
var connection = new RTCPeerConnection(servers);
After this you can add your data channel to this PeerConnection:
var dataChannel = connection.createDataChannel("channelName",{ reliable: true });
When this is done you can just call sendChannel.send('Any data you want');
and this will send any data you want.
If anything, I found this book really helpful. It leaves a lot of unanswered questions, but for the first start it is good.