1+ use crate :: Application ;
2+ use crate :: message:: resend_request:: ResendRequest ;
3+ use crate :: session:: ctx:: { SessionCtx , TransitionResult } ;
4+ use crate :: session:: error:: { InternalSendResultExt , SessionOperationError } ;
5+ use crate :: session:: inbound:: { self , VerificationOutcome } ;
6+ use crate :: session:: outbound;
7+ use crate :: session:: state:: { AwaitingResendState , SessionState } ;
18use crate :: transport:: writer:: WriterRef ;
9+ use hotfix_message:: message:: Message ;
10+ use hotfix_store:: MessageStore ;
211use tokio:: time:: Instant ;
12+ use tracing:: debug;
313
414pub ( crate ) struct AwaitingLogonState {
515 /// The writer's reference to send messages to the counterparty
@@ -9,3 +19,40 @@ pub(crate) struct AwaitingLogonState {
919 /// When we are expecting the Logon response at the latest
1020 pub ( crate ) logon_timeout : Instant ,
1121}
22+
23+ impl AwaitingLogonState {
24+ pub ( crate ) async fn handle_verification_issue < A : Application , S : MessageStore > (
25+ & self ,
26+ ctx : & mut SessionCtx < A , S > ,
27+ message : & Message ,
28+ check_too_high : bool ,
29+ check_too_low : bool ,
30+ ) -> Result < TransitionResult , SessionOperationError > {
31+ match inbound:: verify_and_handle_errors (
32+ ctx,
33+ & self . writer ,
34+ message,
35+ check_too_high,
36+ check_too_low,
37+ )
38+ . await
39+ {
40+ VerificationOutcome :: Ok => Ok ( TransitionResult :: Stay ) ,
41+ VerificationOutcome :: Handled ( result) => Ok ( result) ,
42+ VerificationOutcome :: SequenceGap { expected, actual } => {
43+ debug ! (
44+ "we are behind target (ours: {expected}, theirs: {actual}), requesting resend."
45+ ) ;
46+ let awaiting_resend =
47+ AwaitingResendState :: new ( self . writer . clone ( ) , expected, actual) ;
48+ let request = ResendRequest :: new ( expected, actual) ;
49+ outbound:: send_message ( ctx, & self . writer , request)
50+ . await
51+ . with_send_context ( "resend request" ) ?;
52+ Ok ( TransitionResult :: TransitionTo (
53+ SessionState :: AwaitingResend ( awaiting_resend) ,
54+ ) )
55+ }
56+ }
57+ }
58+ }
0 commit comments