File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -339,20 +339,8 @@ where
339339 }
340340
341341 async fn on_logon ( & mut self ) -> Result < ( ) , SessionOperationError > {
342- if let SessionState :: AwaitingLogon ( AwaitingLogonState { writer, .. } ) = & self . state {
343- let writer = writer. clone ( ) ;
344- // happy logon flow, the session is now active
345- self . apply_transition ( TransitionResult :: TransitionTo ( SessionState :: new_active (
346- writer,
347- self . ctx . config . heartbeat_interval ,
348- ) ) )
349- . await ;
350- self . ctx . application . on_logon ( ) . await ;
351- self . ctx . store . increment_target_seq_number ( ) . await ?;
352- } else {
353- error ! ( "received unexpected logon message" ) ;
354- }
355-
342+ let transition = self . state . on_peer_logon ( & mut self . ctx ) . await ?;
343+ self . apply_transition ( transition) . await ;
356344 Ok ( ( ) )
357345 }
358346
Original file line number Diff line number Diff line change @@ -63,6 +63,21 @@ impl SessionState {
6363 } )
6464 }
6565
66+ /// Handles a Logon message from the peer. Only AwaitingLogon produces a
67+ /// transition — all other states log an error and stay.
68+ pub ( crate ) async fn on_peer_logon < A : Application , S : MessageStore > (
69+ & self ,
70+ ctx : & mut SessionCtx < A , S > ,
71+ ) -> Result < TransitionResult , SessionOperationError > {
72+ match self {
73+ Self :: AwaitingLogon ( state) => state. on_peer_logon ( ctx) . await ,
74+ _ => {
75+ error ! ( "received unexpected logon message" ) ;
76+ Ok ( TransitionResult :: Stay )
77+ }
78+ }
79+ }
80+
6681 /// Returns the transition to apply when a Logout message is received from the peer.
6782 /// Each state determines its own reconnect policy and disconnect reason.
6883 pub ( crate ) fn on_peer_logout ( & self ) -> TransitionResult {
Original file line number Diff line number Diff line change @@ -38,6 +38,18 @@ impl AwaitingLogonState {
3838 }
3939 }
4040
41+ pub ( crate ) async fn on_peer_logon < A : Application , S : MessageStore > (
42+ & self ,
43+ ctx : & mut SessionCtx < A , S > ,
44+ ) -> Result < TransitionResult , SessionOperationError > {
45+ ctx. application . on_logon ( ) . await ;
46+ ctx. store . increment_target_seq_number ( ) . await ?;
47+ Ok ( TransitionResult :: TransitionTo ( SessionState :: new_active (
48+ self . writer . clone ( ) ,
49+ ctx. config . heartbeat_interval ,
50+ ) ) )
51+ }
52+
4153 pub ( crate ) async fn handle_verification_issue < A : Application , S : MessageStore > (
4254 & self ,
4355 ctx : & mut SessionCtx < A , S > ,
You can’t perform that action at this time.
0 commit comments