Skip to content

How to cancel a Udp stream #4533

Answered by Darksonn
Sheap asked this question in Q&A
Feb 24, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Give this a try:

let (send, mut recv) = tokio::sync::mpsc::channel::<()>();
app_handle.listen_global("udp_close", move |_| {
    println!("got close command");
    send.send(());
});

app_handle.emit_all("udp_listening", true).unwrap();

tokio::select! {
    _ = udp_listener => {},
    _ = recv.recv() => {},
}
println!("closed");
Ok(())

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Sheap
Comment options

@Darksonn
Comment options

@Sheap
Comment options

Answer selected by Sheap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants