Sockey – A P2P multiplayer soccer game based on WebRTC
sockey.eu
sockey.eu
1. Don't signal TCP ICE candidates. 2. Don't provide TCP TURN servers.
If you do those two things, it's impossible to get a TCP connection. In fact, just doing #2 will nearly guarantee it (since a TCP connection outside of TURN is so rare).
But ICE will almost always prefer UDP over TCP, so if it's using TCP it's because otherwise you simply wouldn't be connected at all. And if you'd prefer not to be connected, you could simply close the connection when you observe it's over TCP.
Last time I tried to get the chromium builds going on win32 was 3 hours of complete failure and obscure error messages because of various "non-googler" flags. The WebRTC page basically says you can't do Android development if you don't have a Linux machine [1].
There's been a bunch of game studios that started down the path of WebRTC and basically gave up since it's so hard to integrate. Compare that with 2-3 C files and a couple headers + libsodium for something like Netcode.io.
Also game servers don't really care about congestion control. They rarely break ~15kbps of continuous data per client versus something that scales up with bandwidth like a file transfer. Any case where congestion control is an issue should be something that needs to negotiated over a TCP stream anyway(otherwise you're just reinventing TCP over UDP).
[1] https://webrtc.org/native-code/development/prerequisite-sw/
Congestion control isn't going to help when a bad actor spoofs your protocol and dump GBs of data on you.
If I am not mistaken, it is at least possible to detect whether UDP is available using the protocol property of the RTCIceCandidate. [1]
I mean fundamentally the goals of WebRTC and game engines just aren't that well aligned. All games are going to want an authoritative server to hold the master state and reconcile clients. Where as WebRTC is very much interesting in P2P. All the STUN, TURN and ICE stuff is pretty much wasted on a game server.
The spec is also way over complicated, heck it covers DTMF for crying out loud.
Having experimented a bit with WebRTC myself, I agree that it is overly complex but it also offers many features. And if usage is too complicated for game developers, they can still libraries that simplify the usage for their purpose.
And while WebRTC is complex, you can ignore almost all of that if you're just doing client to server data channels. You just need to speak ICE lite, DTLS, and SCTP, all of which have libraries. See some of my comments from months ago for more details.
I think your proving my point here. That's a lot more to ask than a simple libsodium based crypto + auth token that something like Netcode.io uses.
https://github.com/Maksims/web-udp-public
https://new.gafferongames.com/post/why_cant_i_send_udp_packe...
Web assembly even extends the possibilities game creators already have for creating browser-based games.
Even if P2P in this case meant that all clients were connected to each other, you could still have each client maintain its own state and only transmit the user input. I do not see why this should not work well as long as the majority uses honest clients.
Disclaimer: I am not related to the game creator.
Too bad, the game would have been really fun to play if controls were usable for me.