2

I was wondering if it was okay to use WebRTC as an alternative for WebSockets. From what I know (which is very little), WebRTC's RTCDataChannels are basically P2P connections which connect in Real Time. If I replace a peer with a server wouldn't I get something like WebSockets, but real time? Is this possible? If so what are the pros and cons? Is this a good idea?
Thanks in advance.

Some Dinosaur
  • 154
  • 1
  • 14
  • 1
    What kind of "time" do you think WebSockets are? WebRTC's "realtime" isn't any realer than WebSockets for most practical purposes… – deceze Aug 29 '16 at 14:02

1 Answers1

1

When using WebRTC you would still need a signaling solution, which very often still resides to websockets. Anyway these two are not interchangeable, though you might achieve the same thing in many situation.

WebSockets are used for client-server communication, as opposed to WebRTC (DataChannels) used for client-client (peer-to-peer) communication.

When it comes to implementation, WebSockets have better support on browsers, than WebRTC. Also they're easier to implement.

See another case here: should I use websockets or webRTC for 4player game

Community
  • 1
  • 1
Adrian Ber
  • 20,474
  • 12
  • 67
  • 117