0

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?

Mike
  • 493
  • 5
  • 14

1 Answers1

1

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).

jib
  • 40,579
  • 17
  • 100
  • 158