No longer accept to send after close

pull/74/head
Naja Melan 5 years ago
parent 2004309814
commit 2918eec1b3
  1. 7
      src/protocol/mod.rs

@ -230,9 +230,14 @@ impl WebSocketContext {
where
Stream: Read + Write,
{
// Do not write to already closed connections.
// When terminated, return AlreadyClosed.
self.state.check_active()?;
// Do not write after sending a close frame.
if !self.state.is_active() {
return Err(Error::Protocol("Sending after closing is not allowed".into()));
}
if let Some(max_send_queue) = self.config.max_send_queue {
if self.send_queue.len() >= max_send_queue {
// Try to make some room for the new message.

Loading…
Cancel
Save