Reputation: 97
I am trying to understand the use of websockets in webrtc, I created a websocket, connected to it succefully. using a stun server to get the ip address of the devices ( which devices ??) it returns me ice candidates ( how am i supposed to use them to connect to my brother on his phone ?? )
stun server used - stun:stun.l.google.com:19302
i understand webrtc captures our video/audio and create peer connections (but with whome does it make peer connection, whome is it sending the connection offer to? where does the websockets come in all this ? what part does the websockets have to play, do i have to register each user on the server using websocket ? )
Unable to understand the concept of websockets in layman's language.
P.S. i used a random link from net as websocket from some tutorial - https://appr.tc/join/
the response i get is succesfully connected.
Thanks.
Upvotes: 0
Views: 3375
Reputation: 2643
WebRTC is having following two main API's
getUserMedia : to capture Audio/Video etc
peerConnection : Establish the communication channel between the peers using signalling messages(offer/answer/candidates) to transmit the media/data.
So we need a channel to relay these offer/answer/candidates between peers. WebRTC is independent of this comm channel, so you can choose one like WebSocket/Ajax/RestAPI/IM...
First try the basic demo, it works without any signalling channel as both peers are in same window.
AppRTC demo is room based, both the peers should use the same roomId then they will exchange messages with WebSocket.
So in your case have a simple setup with signalling server,
All peers will connect to sever over WebSocket.
If you want to talk with your brother, create offer and ask your server to send the offer to you bro's websocket connection.
Then your brother has to create the answer and send it back you via server.
And you both have to exchange the candidates.
As long as you are in normal network, google stun server ( stun:stun.l.google.com:19302
) will work. If you behind complex NAT, then you need to setup your own TURN server. Read more
Upvotes: 1