DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
20.46k stars 786 forks source link

How do perform web socket IO from a Dioxus web app? An example would be helpful #2143

Closed chmorgan closed 6 months ago

chmorgan commented 6 months ago

My web app needs to handle data streamed from a web socket but I'm struggling to figure out how (or if this is possible with wasm targets).

An example of how to use web sockets with Dioxus would be helpful.

jkelleyrtp commented 6 months ago

This crate is out of date but the code is small enough for you to drop into your project.

https://github.com/FruitieX/dioxus-websocket-hooks/blob/master/src/lib.rs

sjames commented 6 months ago

The reqwest-websocket crate works too. https://crates.io/crates/reqwest-websocket

chmorgan commented 6 months ago

For my use case it was important that a web application be possible. As the application would be using web sockets, I was looking to see if that fit in with what dioxus might support. It's actually been a significant amount of effort, and thank you and @sjames for those links, to figure out how to do web sockets with wasm.

tokio-tungstenite wasm support would be awesome (https://github.com/tokio-rs/tokio/issues/1597) but doesn't appear to be in progress.

In any case, it could help others using dioxus if there was an example showing how to do cross platform web sockets.