The pingSender makes sure that we've sent a message within the last PingSendInterval. If we already have something sent in the last PingSendInterval/2, we do nothing. Otherwise we send a ping message. This results in an effecting ping interval of somewhere between PingSendInterval/2 and PingSendInte
()
| 1001 | // results in an effecting ping interval of somewhere between |
| 1002 | // PingSendInterval/2 and PingSendInterval. |
| 1003 | func (c *rawConnection) pingSender() { |
| 1004 | ticker := time.NewTicker(PingSendInterval / 2) |
| 1005 | defer ticker.Stop() |
| 1006 | |
| 1007 | for { |
| 1008 | select { |
| 1009 | case <-ticker.C: |
| 1010 | d := time.Since(c.cw.Last()) |
| 1011 | if d < PingSendInterval/2 { |
| 1012 | l.Debugln(c.deviceID, "ping skipped after wr", d) |
| 1013 | continue |
| 1014 | } |
| 1015 | |
| 1016 | l.Debugln(c.deviceID, "ping -> after", d) |
| 1017 | c.ping() |
| 1018 | |
| 1019 | case <-c.closed: |
| 1020 | return |
| 1021 | } |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | // The pingReceiver checks that we've received a message (any message will do, |
| 1026 | // but we expect pings in the absence of other messages) within the last |