forked from cryptogarageinc/quickfix-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logon_state.go
30 lines (23 loc) · 836 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
package quickfix
type logonState struct{}
func (state 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 && string(msgType) == "A" {
if err := session.handleLogon(msg); err != nil {
session.log.OnEvent(err.Error())
return latentState{}
}
return inSession{}
}
session.log.OnEventf("Invalid Session State: Received Msg %v while waiting for Logon", msg)
return latentState{}
}
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
}