|
|
@ -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.
|
|
|
|
// No data processing while closing.
|
|
|
|
Ok(None) |
|
|
|
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.
|
|
|
|
/// Check if the state is active, return error if not.
|
|
|
|
fn check_active(&self) -> Result<()> { |
|
|
|
fn check_active(&self) -> Result<()> { |
|
|
|
match self { |
|
|
|
match self { |
|
|
|