Skip to content

Commit

Permalink
Handle close messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Jul 17, 2024
1 parent 87d7b14 commit 6791919
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lighthouse-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub enum Error {
Server { code: i32, message: Option<String>, warnings: Vec<String> },
#[error("No next message available")]
NoNextMessage,
#[error("The connection was closed")]
ConnectionClosed,
#[error("Custom error")]
Custom(String),
}
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-client/src/lighthouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ impl<S> Lighthouse<S>
let message = ws_stream.next().await.ok_or_else(|| Error::NoNextMessage)??;
match message {
Message::Binary(bytes) => break Ok(bytes),
// We ignore pings for now
Message::Ping(_) => {},
Message::Ping(_) => {}, // Ignore pings for now
Message::Close(_) => break Err(Error::ConnectionClosed),
_ => warn!("Got non-binary message: {:?}", message),
}
}
Expand Down

0 comments on commit 6791919

Please sign in to comment.