rust-socketio
rust-socketio copied to clipboard
wasm support
I'm looking for a socket io client crate that works on both wasm and native. Is this something you'd want to add?
What exactly do you mean by working with Wasm? Right now you could compile the crate to Wasm using Emscripten's runtime: cargo build --target wasm32-unknown-emscripten
. What you mean is probably interoperability with JS via wasm_bindgen
. The problem here is, that you then usually compile to the target wasm32-unknown-unknown
, which doesn't compile with stdio things like threads and networking (stuff that this crate uses extensively). A possible solution would be to add #![cfg(target_arch = "wasm32")]
flags to those functions and sub it with the bindings from web-sys
. I generally would like to see that this crate works with Wasm, also because I think that this would be a use case.
Yes, the use case I have is that I want to be able to run the same code without modifications both in the browser and as a native application.
Ups sorry! I think in order to get this started one could look at how reqwest
(the http library used here) implemented Wasm support (mainly in src/wasm
or src/lib.rs
). We would also need to somehow factor out the thread that starts the polling cycle and threads that start the callback (currently through the spawn_scoped!
macro). Async support before this (see Roadmap.md) would come in handy because async is supported by the browser.
If looked further into this and WASI could be an option as well. WASI provides sort of a normal standard library for WebAssembly and is both supported by the browser and the most common runtimes. It is accessible via the wasm32-wasi
target. It provides a std implementation, but yields unimplemented!()
calls on the functions unavailable in the browser.
A build error related to openssl is found while I am trying to use it in an app built on wasm and rust.
Yes, this is not yet implemented. There is no support for the WASM target yet.
Yes, this is not yet implemented. There is no support for the WASM target yet.
Got it :) You have aldeady done great job. It 's nice to see more and more frontend frameworks wrintten in rust.
any update on this? i would like to use socketio client within leptos but got the same error with wasm
I am ok if only can compile to wasm only so I can use it with my browser extension.
currently getting error for getrandom crate when compiling with wasm-pack.
wants to be added js feature