lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
662 stars 68 forks source link

Is a WASM client possible? #62

Closed stnbu closed 1 year ago

stnbu commented 1 year ago

I've been trying to get demo_bevy to compile to WASM and work. In my JS console I get a terse error printed that points me to the UdpSocket::bind call in the client code. So I'm assuming this just isn't a thing in browser WASM land (no way to simply bind to the network interface... obvious in retrospect.)

I don't really know what my options are. WebSockets is TCP and probably not appropriate. I believe there's some hack to let you relay network data from JavaScript land to WASM land via javascript function calls.

Good advice also counts as resolution in my case. Thanks for the really cool crate!

dw-rs commented 1 year ago

I am also very much interested in a WASM compatible version.

lucaspoffo commented 1 year ago

Currently, there is no compatibility since the library uses UDP for networking. There is some effort to use traits for the transport so it would be able to make a transport layer compatible with WASM. But that won't happen so soon

Trait PR: https://github.com/lucaspoffo/renet/pull/36

stnbu commented 1 year ago

Cool! I'll keep an eye on #36 and contribute somehow if I'm able to. Thanks!