Merge commit 'e3c0ec30c8ed427d65abc8a7d76d003887f97016' into devel

pull/13/head
Alexey Galakhov 7 years ago
commit 626333bc1d
  1. 10
      src/protocol/mod.rs

@ -293,9 +293,16 @@ impl<Stream: Read + Write> WebSocket<Stream> {
} // match opcode
} else {
match replace(&mut self.state, WebSocketState::Terminated) {
WebSocketState::CloseAcknowledged(close) | WebSocketState::ClosedByPeer(close) => {
Err(Error::ConnectionClosed(close))
}
_ => {
Err(Error::Protocol("Connection reset without closing handshake".into()))
}
}
}
}
/// Received a close frame.
fn do_close(&mut self, close: Option<CloseFrame>) -> Result<()> {
@ -342,6 +349,7 @@ impl<Stream: Read + Write> WebSocket<Stream> {
}
}
}
WebSocketState::Terminated => unreachable!(),
}
}
@ -413,6 +421,8 @@ enum WebSocketState {
ClosedByPeer(Option<CloseFrame<'static>>),
/// The peer replied to our close handshake.
CloseAcknowledged(Option<CloseFrame<'static>>),
/// The connection does not exist anymore.
Terminated,
}
impl WebSocketState {

Loading…
Cancel
Save