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.
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
Read more here: Source link