Skip to content

Commit

Permalink
Refactor heartbeat task to support WebAssembly
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfl0wer committed Nov 20, 2023
1 parent 325c3d3 commit f0a4fe6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gateway/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f0a4fe6

Please sign in to comment.