Closed ValorZard closed 3 years ago
I'll be honest: I have absolutely no prior knowledge of web-based stuff.
I might take a look in the future, but it is definitely not something I can just add.
PR #18 is a first step to WASM compatability.
I copied the bevy_ggrs box_game_p2p example into the bevy_webgl2 template and got it to build with latest bevy and stop panicking. https://github.com/johanhelsing/bevy_ggrs_box_game_web
I didn't actually start on replacing udp with werbrtc, but thought I'd just share the example as it's a good place to start if someone else wants to try tinkering as well.
You can pass in "command line" args in the query string, so http://127.0.0.1:4000/?players[0]=localhost&players[1]=1.2.3.4:1234
will start the game with one local player and waiting for the other player to join (assuming you comment out udp stuff in ggrs itself).
Since I would love GGRS to stay a 100% rust project without any dependencies from other languages, my current suggestion is to wait for https://github.com/webrtc-rs/webrtc to finish implementing the webRTC protocol and revisit this issue from there.
We might want further changes in ggrs to make the usage nicer, but that's enough for a minimal implementation :)
I put all my webrtc related code in a separate repo, Matchbox. The matchbox_socket
crate implements the ggrs::NonBlockingSocket
trait if the ggrs-socket
feature is enabled.
I put it there for now, but we could consider moving the ggrs integration code over to ggrs instead... not sure what makes the most sense.
In any case I wrote a blog post about it: https://johanhelsing.studio/posts/introducing-matchbox And the repo is here: https://github.com/johanhelsing/matchbox.
With the matchbox demo showcasing that GGRS works in a WASM environment, I will close this issue for now.
Since the UDP bindings are just a single file, it shouldn't be too bad to add webrtc support. The problem with that is only that webrtc itself is a fickle beast, but that just comes with exporting to web.