pub(super) fn on_ws_close(
core: &mut ProtocolCore,
close_code: u16,
) -> Vec<Command>Expand description
handles websocket closure after a user was already in flight
there are three different cases here and mixing them up is the main way to break reconnect behavior:
- terminal close codes move to
ConnectionState::Closed, clear the saved connect context, and suppress recovery - non-terminal closes with saved connect context move to
ConnectionState::Recoveringand schedule the recovery timer - non-terminal closes without saved connect context fall back to
ConnectionState::Disconnected, because there is nothing safe to reconnect to
example:
Connected --on_ws_close(AuthFailed)--> Closed
Connected --on_ws_close(1011)--> Recovering