Skip to content

Commit 1ad4f39

Browse files
committed
Add Lighthouse::close
1 parent 03174b4 commit 1ad4f39

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lighthouse-client/src/lighthouse.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,11 @@ impl<S> Lighthouse<S>
295295
pub fn authentication(&self) -> &Authentication {
296296
&self.authentication
297297
}
298+
299+
/// Closes the WebSocket connection gracefully with a close message. While
300+
/// the server will usually also handle abruptly closed connections
301+
/// properly, it is recommended to always close the [``Lighthouse``].
302+
pub async fn close(&self) -> Result<()> {
303+
Ok(self.ws_sink.lock().await.close().await?)
304+
}
298305
}

0 commit comments

Comments
 (0)