forked from quickfixgo/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logon_state.go
48 lines (39 loc) · 1.25 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package quickfix
import "github.com/quickfixgo/quickfix/enum"
type logonState struct{}
func (state logonState) String() string { return "Logon State" }
func (s logonState) IsLoggedOn() bool { return false }
func (s logonState) VerifyMsgIn(session *session, msg Message) MessageRejectError {
var msgType FIXString
if err := msg.Header.GetField(tagMsgType, &msgType); err != nil {
return RequiredTagMissing(tagMsgType)
}
switch string(msgType) {
case enum.MsgType_LOGON:
err := session.verifyLogon(msg)
if err != nil {
session.log.OnEvent(err.Error())
}
return err
default:
session.log.OnEventf("Invalid Session State: Received Msg %v while waiting for Logon", msg)
return InvalidMessageType()
}
}
func (s logonState) FixMsgIn(session *session, msg Message) (nextState sessionState) {
if err := session.handleLogon(msg); err != nil {
session.log.OnEvent(err.Error())
return latentState{}
}
return inSession{}
}
func (s logonState) FixMsgInRej(session *session, msg Message, err MessageRejectError) sessionState {
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
}