diff --git a/src/ws/mod.rs b/src/ws/mod.rs index b6835fc..6664af2 100644 --- a/src/ws/mod.rs +++ b/src/ws/mod.rs @@ -227,6 +227,13 @@ impl Websocket { self.send(true, protocol::op::PING, body) } + #[inline] + pub fn send_close(&mut self) -> Result<(), Error> { + self.send(true, protocol::op::CONNECTION_CLOSE, None)?; + self.closed = true; + Ok(()) + } + #[inline] fn next(&mut self) -> Result, Error> { self.ensure_not_closed()?;