Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jayhuang75/04ba6d4629277ec87ea3bf88cbab128e to your computer and use it in GitHub Desktop.
Save jayhuang75/04ba6d4629277ec87ea3bf88cbab128e to your computer and use it in GitHub Desktop.
nextjs-rust-twitter-streaming-websocket-split.rs
let (client_ws_sender, mut _client_ws_rcv) = ws.split();
let (client_sender, client_rcv) = mpsc::unbounded_channel();
let client_rcv = UnboundedReceiverStream::new(client_rcv);
tokio::task::spawn(client_rcv.forward(client_ws_sender).map(|result| {
if let Err(e) = result {
log::error!("Failed toerror sending websocket msg: {}", e);
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment