|
|
|
@ -280,7 +280,9 @@ impl WebSocketContext { |
|
|
|
|
|
|
|
|
|
// Do not write after sending a close frame.
|
|
|
|
|
if !self.state.is_active() { |
|
|
|
|
return Err(Error::Protocol("Sending after closing is not allowed".into())); |
|
|
|
|
return Err(Error::Protocol( |
|
|
|
|
"Sending after closing is not allowed".into(), |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if let Some(max_send_queue) = self.config.max_send_queue { |
|
|
|
@ -378,7 +380,9 @@ impl WebSocketContext { |
|
|
|
|
{ |
|
|
|
|
if let Some(mut frame) = self.frame.read_frame(stream, self.config.max_frame_size)? { |
|
|
|
|
if !self.state.can_read() { |
|
|
|
|
return Err(Error::Protocol("Remote sent frame after having sent a Close Frame".into())); |
|
|
|
|
return Err(Error::Protocol( |
|
|
|
|
"Remote sent frame after having sent a Close Frame".into(), |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
// MUST be 0 unless an extension is negotiated that defines meanings
|
|
|
|
|
// for non-zero values. If a nonzero value is received and none of
|
|
|
|
@ -600,8 +604,7 @@ impl WebSocketState { |
|
|
|
|
/// close frame, so we should still pass those to client code, hence ClosedByUs is valid.
|
|
|
|
|
fn can_read(&self) -> bool { |
|
|
|
|
match self { |
|
|
|
|
WebSocketState::Active | |
|
|
|
|
WebSocketState::ClosedByUs => true, |
|
|
|
|
WebSocketState::Active | WebSocketState::ClosedByUs => true, |
|
|
|
|
_ => false, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|