File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -73,17 +73,21 @@ func NewClient(protoOptions protocol.ProtocolOptions, cfg *Config) *Client {
7373func (c * Client ) Start () {
7474 c .onceStart .Do (func () {
7575 c .Protocol .Start ()
76- c .startTimer ()
76+ c .sendKeepAlive ()
7777 })
7878}
7979
80+ func (c * Client ) sendKeepAlive () {
81+ msg := NewMsgKeepAlive (c .config .Cookie )
82+ if err := c .SendMessage (msg ); err != nil {
83+ c .SendError (err )
84+ }
85+ // Reschedule timer
86+ c .startTimer ()
87+ }
88+
8089func (c * Client ) startTimer () {
81- c .timer = time .AfterFunc (c .config .Period , func () {
82- msg := NewMsgKeepAlive (c .config .Cookie )
83- if err := c .SendMessage (msg ); err != nil {
84- c .SendError (err )
85- }
86- })
90+ c .timer = time .AfterFunc (c .config .Period , c .sendKeepAlive )
8791}
8892
8993func (c * Client ) messageHandler (msg protocol.Message ) error {
You can’t perform that action at this time.
0 commit comments