|
|
@ -283,9 +283,11 @@ impl WebSocketContext { |
|
|
|
// response, unless it already received a Close frame. It SHOULD
|
|
|
|
// response, unless it already received a Close frame. It SHOULD
|
|
|
|
// respond with Pong frame as soon as is practical. (RFC 6455)
|
|
|
|
// respond with Pong frame as soon as is practical. (RFC 6455)
|
|
|
|
if let Some(pong) = self.pong.take() { |
|
|
|
if let Some(pong) = self.pong.take() { |
|
|
|
|
|
|
|
trace!("Sending pong reply"); |
|
|
|
self.send_one_frame(stream, pong)?; |
|
|
|
self.send_one_frame(stream, pong)?; |
|
|
|
} |
|
|
|
} |
|
|
|
// If we have any unsent frames, send them.
|
|
|
|
// If we have any unsent frames, send them.
|
|
|
|
|
|
|
|
trace!("Frames still in queue: {}", self.send_queue.len()); |
|
|
|
while let Some(data) = self.send_queue.pop_front() { |
|
|
|
while let Some(data) = self.send_queue.pop_front() { |
|
|
|
self.send_one_frame(stream, data)?; |
|
|
|
self.send_one_frame(stream, data)?; |
|
|
|
} |
|
|
|
} |
|
|
@ -301,6 +303,7 @@ impl WebSocketContext { |
|
|
|
// maximum segment lifetimes (2MSL), while there is no corresponding
|
|
|
|
// maximum segment lifetimes (2MSL), while there is no corresponding
|
|
|
|
// server impact as a TIME_WAIT connection is immediately reopened upon
|
|
|
|
// server impact as a TIME_WAIT connection is immediately reopened upon
|
|
|
|
// a new SYN with a higher seq number). (RFC 6455)
|
|
|
|
// a new SYN with a higher seq number). (RFC 6455)
|
|
|
|
|
|
|
|
self.state = WebSocketState::Terminated; |
|
|
|
Err(Error::ConnectionClosed) |
|
|
|
Err(Error::ConnectionClosed) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
@ -519,6 +522,7 @@ impl WebSocketContext { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trace!("Sending frame: {:?}", frame); |
|
|
|
let res = self.frame.write_frame(stream, frame); |
|
|
|
let res = self.frame.write_frame(stream, frame); |
|
|
|
// An expected "Connection reset by peer" is not fatal
|
|
|
|
// An expected "Connection reset by peer" is not fatal
|
|
|
|
match res { |
|
|
|
match res { |
|
|
@ -563,8 +567,6 @@ 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::ClosedByPeer | WebSocketState::CloseAcknowledged |
|
|
|
|
|
|
|
=> Err(Error::ConnectionClosed), |
|
|
|
|
|
|
|
WebSocketState::Terminated |
|
|
|
WebSocketState::Terminated |
|
|
|
=> Err(Error::AlreadyClosed), |
|
|
|
=> Err(Error::AlreadyClosed), |
|
|
|
_ => Ok(()), |
|
|
|
_ => Ok(()), |
|
|
|