add wasm friendly task spawning
This commit is contained in:
parent
f8979b7feb
commit
022bf9f320
|
@ -2,6 +2,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
use futures_util::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
use log::*;
|
use log::*;
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
|
|
||||||
use self::event::Events;
|
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
|
// 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 {
|
task::spawn(async move {
|
||||||
gateway.gateway_listen_task().await;
|
gateway.gateway_listen_task().await;
|
||||||
});
|
});
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
wasm_bindgen_futures::spawn_local(async move {
|
||||||
|
gateway.gateway_listen_task().await;
|
||||||
|
});
|
||||||
|
|
||||||
Ok(GatewayHandle {
|
Ok(GatewayHandle {
|
||||||
url: websocket_url.clone(),
|
url: websocket_url.clone(),
|
||||||
|
|
Loading…
Reference in New Issue