Update example to not broadcast close messages.

In the event that the client sends a close message,
it is broadcast to other clients closing them as well.
pull/26/head
Mark Lodato 5 years ago committed by Sebastian Dröge
parent 6bffd862b6
commit 70c77160a9
  1. 8
      examples/server.rs

@ -52,7 +52,13 @@ async fn handle_connection(peer_map: PeerMap, raw_stream: TcpStream, addr: Socke
let (outgoing, incoming) = ws_stream.split();
let broadcast_incoming = incoming.try_for_each(|msg| {
let broadcast_incoming = incoming
.try_filter(|msg| {
// Broadcasting a Close message from one client
// will close the other clients.
future::ready(!msg.is_close())
})
.try_for_each(|msg| {
println!(
"Received a message from {}: {}",
addr,

Loading…
Cancel
Save