forked from quickfixgo/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resend_state.go
29 lines (22 loc) · 896 Bytes
/
resend_state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package quickfix
type resendState struct {
inSession
}
func (state resendState) String() string { return "Resend" }
func (state resendState) FixMsgIn(session *session, msg Message) (nextState sessionState) {
return state.handleNextState(session, state.inSession.FixMsgIn(session, msg))
}
func (state resendState) FixMsgInRej(session *session, msg Message, rej MessageRejectError) (nextState sessionState) {
return state.handleNextState(session, state.inSession.FixMsgInRej(session, msg, rej))
}
func (state resendState) handleNextState(session *session, nextState sessionState) sessionState {
if !nextState.IsLoggedOn() || len(session.messageStash) == 0 {
return nextState
}
targetSeqNum := session.store.NextTargetMsgSeqNum()
if msg, ok := session.messageStash[targetSeqNum]; ok {
delete(session.messageStash, targetSeqNum)
session.resendIn <- msg
}
return resendState{}
}