-
Notifications
You must be signed in to change notification settings - Fork 0
/
logon_state.go
33 lines (26 loc) · 905 Bytes
/
logon_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
30
31
32
33
package quickfix
import "github.com/quickfixgo/quickfix/enum"
type logonState struct{}
func (s logonState) String() string { return "Logon State" }
func (s logonState) IsLoggedOn() bool { return false }
func (s logonState) FixMsgIn(session *session, msg Message) (nextState sessionState) {
var msgType FIXString
if err := msg.Header.GetField(tagMsgType, &msgType); err != nil {
return session.handleError(err)
}
if string(msgType) != enum.MsgType_LOGON {
session.log.OnEventf("Invalid Session State: Received Msg %s while waiting for Logon", msg)
return latentState{}
}
if err := session.handleLogon(msg); err != nil {
return session.handleError(err)
}
return inSession{}
}
func (s logonState) Timeout(session *session, e event) (nextState sessionState) {
if e == logonTimeout {
session.log.OnEvent("Timed out waiting for logon response")
return latentState{}
}
return s
}