Keep processing incoming data even after we have initiated a close handshake.

pull/72/head
Naja Melan 5 years ago
parent a3625fbaa9
commit b923ec42c0
  1. 13
      src/protocol/mod.rs

@ -396,7 +396,7 @@ impl WebSocketContext {
}
}
OpCode::Data(_) if !self.state.is_active() => {
OpCode::Data(_) if !self.state.can_read() => {
// No data processing while closing.
Ok(None)
}
@ -556,6 +556,17 @@ impl WebSocketState {
}
}
/// Tell if we should process incoming data. Note that if we send a close frame
/// but the remote hasn't confirmed, they might have sent data before they receive our
/// 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,
_ => false,
}
}
/// Check if the state is active, return error if not.
fn check_active(&self) -> Result<()> {
match self {

Loading…
Cancel
Save