Marco
Marco

Reputation: 33

Using user ID with WEBRTC

I'm trying to develop a WEBRTC videochat on a website. I've already create my database with users and their unique ID but I'm a little confused to how I can use this ID to connect clients with PeerConnection. I've already read this http://www.html5rocks.com/en/tutorials/webrtc/basics/ and other documentation but I'm not understanding if i can use users' Id in some way in the remote/local description or I have to use other solutions like PeerJs?

Thanks.

Upvotes: 3

Views: 3094

Answers (2)

jonpd
jonpd

Reputation: 356

In short, WebRTC does not specify the signalling channel (it is up to the developer), ie how users discover and know about each other.

Some tutorials tend to skip the signalling entirely, which is a shame. It might be better to set up your signalling first, verify that it works using your ID method of discovery, and then add WebRTC on top of that.

Upvotes: 3

deceze
deceze

Reputation: 521995

You need to set up signalling yourself. That means, you will need to provide a means for exchanging messages between both users. Just having an id doesn't help anyone in establishing a connection. Both users need to be able to send a message to your server and the server needs to relay that message to the other user they're trying to connect to. You'll probably use the ids in some ways to decide whom to relay to exactly; but that's a secondary implementation detail.

In practice a web socket connection between each user and your server works well. User A sends a message via web socket to your server, your server passes this message on to user B via web socket; repeat that a couple of times until a direct connection has been negotiated.

Upvotes: 2

Related Questions