Newer
Older
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
package server
type idleState struct {
fsm *FSM2
newStateReason string
}
func newIdleState(fsm *FSM2) *idleState {
return &idleState{
fsm: fsm,
}
}
func (s *idleState) run() (state, string) {
for {
switch <-s.fsm.eventCh {
case ManualStart:
s.manualStart()
case AutomaticStart:
s.automaticStart()
default:
continue
}
return newConnectState(s.fsm), s.newStateReason
}
}
func (s *idleState) manualStart() {
s.newStateReason = "Received ManualStart event"
s.start()
}
func (s *idleState) automaticStart() {
s.newStateReason = "Received AutomaticStart event"
s.start()
}
func (s *idleState) start() {
s.fsm.resetConnectRetryCounter()
s.fsm.startConnectRetryTimer()
if s.fsm.active {
s.fsm.tcpConnect()
}
}