4 ms·
Show HN: Making a cross-platform game in Go using WebRTC Datachannels
- valorzard 1y agoHi! I'm the author! Feel free to ask me questions about this
- VikingCoder 1y agoYou specifically mention: "Server dependence: You need to host or use two different servers (Signaling + STUN/TURN). Can use Google’s STUN, but combining signaling and STUN into one server would be nice." I'm curious about using Tailscale with this. I don't think you can just do Tailscale Funnel? But maybe you could? Maybe Tailscale Share, and the client has to also be on Tailscale? I feel like they would go really well together... Thoughts?
- valorzard 1y agoSo, having talked to people in the WebRTC community about this, you should be able to use WebRTC in a local network without having to connect to STUN/TURN STUN/TURN matters because if you are connecting to a remote peer, you have no idea how to reach them. STUN/TURN gives you a "map" to get to the remote peer. If you are on a VPN that doesn't matter very much (see: Hamachi)
- andersmurphy 1y agoYeah if you know the ip of your peer you don't need STUN/TURN from what I remember.
- VikingCoder 1y agoIf it's ipv6, I think that's true. If it's ipv4, then you still have problems. They could be behind NAT or worse, CGNAT.
- Tepix 1y agoHave you looked at Trystero https://oxism.com/trystero https://oxism.com/trystero to establish the WebRTC connection? I used it on a small PoC last week and it worked well. Thanks to latching on to various decentralized services (Nostr etc) you don’t need your own TURN/STUN server etc.
- valorzard 1y agoI'm pretty sure this still uses STUN/TURN [0], it just uses Nostr and friends as a signaling server. Again, the main stumbling block of WebRTC is the signaling server stuff. STUN/TURN is honestly pretty trivial [0] https://github.com/dmotz/trystero/blob/65fa48e33c82a7d0fa627cfd9cb0c5198cc15364/src/peer.js#L196 https://github.com/dmotz/trystero/blob/65fa48e33c82a7d0fa627...
- kamranjon 1y agoThis is great - thanks for posting - I can definitely use Pion in the game I'm working on and it's pretty great that it can compile to wasm and work on the frontend (for the clients)
- jmpavlec 1y ago>Right now, this can only support two players on the same computer So the example only currently works with 2 clients on the same computer? Seems like a pretty substantial limitation. How much more work is it to support other computers and 2+ clients?
- valorzard 1y agoSo, as you can see in the article, there are already games and other projects that have grown past this limitation. The main thing I need to do is honestly just sit down and rewrite the signaling server to make it work for multiple players, and also add CORS support. (to be clear it will already support other computers, just not browsers on remote computers due to lacking CORS support) So yeah this isn't an inherent limitation of WebRTC or anything, it's just writing a good signaling server for WebRTC is annoying
- d0100 1y agoI'm looking at the pion/ebiten example (https://github.com/pion/example-webrtc-applications/tree/master/ebiten-game https://github.com/pion/example-webrtc-applications/tree/mas...) but I can't find where exactly WebRTC comes in The signaling server seems to just be a normal http server
- valorzard 1y agoCheck the /game folder haha. The main.go file has all the stuff related to webrtc And yes, the signaling server IS a normal http server. That’s the whole point. You can set up a WebRTC connection by even just emailing each other the SDPs if you want