forked from lavina/lavina
handle client-side ws error
This commit is contained in:
parent
dd8cf0fbf0
commit
03b0ababa7
|
@ -38,8 +38,7 @@ async fn handle_connection(mut ws_stream: WebSocketStream<Upgraded>, chats: Chat
|
|||
biased;
|
||||
msg = ws_stream.next() => {
|
||||
match msg {
|
||||
Some(msg) => {
|
||||
let msg = msg.unwrap();
|
||||
Some(Ok(msg)) => {
|
||||
let txt = msg.to_text().unwrap().to_string();
|
||||
tracing::info!("Received a message: {txt}, sub_id={sub_id}");
|
||||
match chats.broadcast(format!("{sub_id}: {txt}").as_str()).await {
|
||||
|
@ -49,6 +48,10 @@ async fn handle_connection(mut ws_stream: WebSocketStream<Upgraded>, chats: Chat
|
|||
},
|
||||
}
|
||||
},
|
||||
Some(Err(err)) => {
|
||||
tracing::warn!("Client {sub_id} failure: {err}");
|
||||
break;
|
||||
}
|
||||
None => {
|
||||
tracing::info!("Client {sub_id} closed the socket, stopping..");
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue