mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
close method
This commit is contained in:
1 parent
b6ec22e343
commit
94ea57deac
1 file changed
+12
@@ -167,6 +167,18 @@ impl TwitchWebsocketClient {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn close(&mut self) -> AnyhowResult<()> {
|
||||
let mut socket = match self.socket {
|
||||
None => return Ok(()), // Already closed.
|
||||
Some(ref mut socket) => socket,
|
||||
};
|
||||
|
||||
socket.close(None).await?;
|
||||
self.socket = None;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn is_connected(&self) -> bool {
|
||||
// TODO: This probably isn't accurate
|
||||
self.socket.is_some()
|
||||
|
||||
Reference in new issue
Block a user