@@ -48,7 +48,7 @@ pub(crate) use crate::session::session_ref::InternalSessionRef;
4848pub use crate :: session:: session_ref:: InternalSessionRef ;
4949use crate :: session:: session_ref:: OutboundRequest ;
5050use crate :: session:: state:: SessionState ;
51- use crate :: session:: state:: { AwaitingLogonState , AwaitingLogoutState , TestRequestId } ;
51+ use crate :: session:: state:: { AwaitingLogonState , TestRequestId } ;
5252use crate :: session_schedule:: { SessionPeriodComparison , SessionSchedule } ;
5353use crate :: store:: MessageStore ;
5454use crate :: transport:: writer:: WriterRef ;
@@ -368,26 +368,9 @@ where
368368 . on_logout ( "peer has logged us out" )
369369 . await ;
370370
371- match self . state {
372- // if the session is already disconnected, we have nothing else to do
373- SessionState :: Disconnected ( ..) => { }
374- // if we initiated the logout, preserve the reconnect flag
375- SessionState :: AwaitingLogout ( AwaitingLogoutState { reconnect, .. } ) => {
376- self . state . disconnect_writer ( ) . await ;
377- self . apply_transition ( TransitionResult :: TransitionTo (
378- SessionState :: new_disconnected ( reconnect, "logout completed" ) ,
379- ) )
380- . await ;
381- }
382- // otherwise assume it makes sense to try to reconnect
383- _ => {
384- self . state . disconnect_writer ( ) . await ;
385- self . apply_transition ( TransitionResult :: TransitionTo (
386- SessionState :: new_disconnected ( true , "peer has logged us out" ) ,
387- ) )
388- . await ;
389- }
390- }
371+ self . state . disconnect_writer ( ) . await ;
372+ let transition = self . state . on_peer_logout ( ) ;
373+ self . apply_transition ( transition) . await ;
391374
392375 self . ctx . store . increment_target_seq_number ( ) . await ?;
393376 Ok ( ( ) )
0 commit comments