Hacker News new | ask | show | jobs
by altanis 678 days ago
WebRTC is complicated; there are many more edge cases compared to websockets. Off the top of my head, I know I'd need to run a TURN server for people behind symmetrical NAT or CGNAT networks, which would be a pain. WebSockets are much more accessible for everyone. In the future I'll investigate UDP protocols, but its likely I'll always use TCP for web games.
1 comments

Yes, WebRTC is complicated. But you only need a TURN server for the P2P case. If you are using it in a client-server mode like WebSockets then there is no need for a TURN server, and connection establishment should be significantly simpler. And if you don't need the audio/video stuff then you can ignore that complexity as well. (Although voice chat or even video could be a very cool and differentiating feature for a multiplayer game.)
We work with a lot of multiplayer game devs and always recommend fast-paced games take a second look at client <-> server WebRTC.

This the demo we share: https://github.com/rivet-gg/examples/tree/main/javascript/we...