diff options
Diffstat (limited to 'src/mattermost')
-rw-r--r-- | src/mattermost/client.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mattermost/client.rs b/src/mattermost/client.rs index 83aa5f6..861e0a8 100644 --- a/src/mattermost/client.rs +++ b/src/mattermost/client.rs @@ -78,7 +78,7 @@ impl Client { pub(crate) async fn handle_websocket_stream<T: Handler>( &mut self, handler: T, - mut shutdown: tokio::sync::mpsc::UnboundedReceiver<()>, + mut shutdown: tokio::sync::oneshot::Receiver<()>, ) -> Result<(), anyhow::Error> { let mut ws_stream = self.get_working_ws_stream().await?; loop { @@ -110,17 +110,15 @@ impl Client { debug!("Websocket message: {message:?}"); }, Some(Err(err)) =>{ - warn!("Error while reading message: {err} "); - if matches!(err,tungstenite::Error::Protocol(_)){ - ws_stream = self.get_working_ws_stream().await? - } + return Err(err.into()) } None => { + debug!("Stream closed, restarting"); ws_stream = self.get_working_ws_stream().await? }, } } - _ = shutdown.recv() => { + _ = &mut shutdown => { debug!("Shutting down gracefully"); return Ok(()) } |