Reputation: 27
I'm making real time game for facebook. Now I broadcast state using websockets. But for real-time data udp is much better. I found out that there is WebRTC out there. But I can't use it because it's peer-to-peer and I want authoritative server(the one which runs physics and makes it harder to cheat).
I consider the following options:
What is the best option? Have you implemented one of them and what was the result?
Upvotes: 1
Views: 577
Reputation: 2470
You can definitely build or use a server-side component that will support WebRTC data channels; from the browser/client perspective, it will just be another peer.
Strictly speaking, WebRTC data channels aren't UDP based but SCTP based; but in practice, they provide the kind of flexibility you would need for real-time data exchange (with e.g. the ability to set up connections that favor low latency over reliability).
An example of a server-side component to use data channels would be https://www.npmjs.com/package/rtc-dcstream
Upvotes: 1