Detect and handle MessageStream WebSocket closure.

This commit is contained in:
Sergio Benitez 2024-05-09 22:49:28 -07:00
parent abd7335f77
commit 5cecc9f0be
1 changed files with 1 additions and 0 deletions

View File

@ -278,6 +278,7 @@ impl<'r, S> IoHandler for MessageStream<'r, S>
rocket::tokio::pin!(stream); rocket::tokio::pin!(stream);
while let Some(msg) = stream.next().await { while let Some(msg) = stream.next().await {
let result = match msg { let result = match msg {
Ok(msg) if msg.is_close() => return Ok(()),
Ok(msg) => sink.send(msg).await, Ok(msg) => sink.send(msg).await,
Err(e) => Err(e) Err(e) => Err(e)
}; };