|
|
@ -592,7 +592,7 @@ enum WebSocketState { |
|
|
|
|
|
|
|
|
|
|
|
impl WebSocketState { |
|
|
|
impl WebSocketState { |
|
|
|
/// Tell if we're allowed to process normal messages.
|
|
|
|
/// Tell if we're allowed to process normal messages.
|
|
|
|
fn is_active(&self) -> bool { |
|
|
|
fn is_active(self) -> bool { |
|
|
|
match self { |
|
|
|
match self { |
|
|
|
WebSocketState::Active => true, |
|
|
|
WebSocketState::Active => true, |
|
|
|
_ => false, |
|
|
|
_ => false, |
|
|
@ -602,7 +602,7 @@ impl WebSocketState { |
|
|
|
/// Tell if we should process incoming data. Note that if we send a close frame
|
|
|
|
/// 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
|
|
|
|
/// 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.
|
|
|
|
/// close frame, so we should still pass those to client code, hence ClosedByUs is valid.
|
|
|
|
fn can_read(&self) -> bool { |
|
|
|
fn can_read(self) -> bool { |
|
|
|
match self { |
|
|
|
match self { |
|
|
|
WebSocketState::Active | WebSocketState::ClosedByUs => true, |
|
|
|
WebSocketState::Active | WebSocketState::ClosedByUs => true, |
|
|
|
_ => false, |
|
|
|
_ => false, |
|
|
@ -610,7 +610,7 @@ impl WebSocketState { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// 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 { |
|
|
|
WebSocketState::Terminated => Err(Error::AlreadyClosed), |
|
|
|
WebSocketState::Terminated => Err(Error::AlreadyClosed), |
|
|
|
_ => Ok(()), |
|
|
|
_ => Ok(()), |
|
|
|