Refactor heartbeat task to support WebAssembly

This commit is contained in:
bitfl0wer 2023-11-20 14:57:45 +01:00
parent 3c419e8310
commit 8c2364b8d0
1 changed files with 5 additions and 0 deletions

View File

@ -33,9 +33,14 @@ impl HeartbeatHandler {
let (send, receive) = tokio::sync::mpsc::channel(32);
let kill_receive = kill_rc.resubscribe();
#[cfg(not(target_arch = "wasm32"))]
let handle: JoinHandle<()> = task::spawn(async move {
Self::heartbeat_task(websocket_tx, heartbeat_interval, receive, kill_receive).await;
});
#[cfg(target_arch = "wasm32")]
let handle: JoinHandle<()> = task::spawn_local(move || {
Self::heartbeat_task(websocket_tx, heartbeat_interval, receive, kill_receive);
});
Self {
heartbeat_interval,