diff --git a/src/gateway/gateway.rs b/src/gateway/gateway.rs index 7a3a81d..684b9d2 100644 --- a/src/gateway/gateway.rs +++ b/src/gateway/gateway.rs @@ -2,6 +2,7 @@ use std::time::Duration; use futures_util::{SinkExt, StreamExt}; use log::*; +#[cfg(not(target_arch = "wasm32"))] use tokio::task; use self::event::Events; @@ -74,10 +75,14 @@ impl Gateway { }; // Now we can continuously check for messages in a different task, since we aren't going to receive another hello - // FIXME: Doesn't work in WASM + #[cfg(not(target_arch = "wasm32"))] task::spawn(async move { gateway.gateway_listen_task().await; }); + #[cfg(target_arch = "wasm32")] + wasm_bindgen_futures::spawn_local(async move { + gateway.gateway_listen_task().await; + }); Ok(GatewayHandle { url: websocket_url.clone(),