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;
|
biased;
|
||||||
msg = ws_stream.next() => {
|
msg = ws_stream.next() => {
|
||||||
match msg {
|
match msg {
|
||||||
Some(msg) => {
|
Some(Ok(msg)) => {
|
||||||
let msg = msg.unwrap();
|
|
||||||
let txt = msg.to_text().unwrap().to_string();
|
let txt = msg.to_text().unwrap().to_string();
|
||||||
tracing::info!("Received a message: {txt}, sub_id={sub_id}");
|
tracing::info!("Received a message: {txt}, sub_id={sub_id}");
|
||||||
match chats.broadcast(format!("{sub_id}: {txt}").as_str()).await {
|
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 => {
|
None => {
|
||||||
tracing::info!("Client {sub_id} closed the socket, stopping..");
|
tracing::info!("Client {sub_id} closed the socket, stopping..");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue