Mike
Mike

Reputation: 552

Socket and peer-to-peer connection at once

Is it possible, to mix a socket connection and a peer-to-peer connection within the same script? Let's say a chat application is running on socket.io and the 1 on 1 private messaging should be done within a peer-to-peer connection: Is it necessary to disconnect the running socket.io connection then?

Upvotes: 0

Views: 197

Answers (1)

jib
jib

Reputation: 42490

It's both possible and super common. In fact, it's hard to establish a WebRTC peer connection without having a socket connection first.

This is because WebRTC requires exchanging offer/answer SDP and trickle-ICE messages between the peers ahead of establishing a direct connection.

The MDN tutorial does exactly this. Click on a username in the chat to establish a private video call (demo).

Upvotes: 1

Related Questions