This will fire periodically and send a client origin ping to the server. Will also check that we have received responses from the server.
()
| 5772 | // ping to the server. Will also check that we have received |
| 5773 | // responses from the server. |
| 5774 | func (nc *Conn) processPingTimer() { |
| 5775 | nc.mu.Lock() |
| 5776 | |
| 5777 | if nc.status != CONNECTED { |
| 5778 | nc.mu.Unlock() |
| 5779 | return |
| 5780 | } |
| 5781 | |
| 5782 | // Check for violation |
| 5783 | nc.pout++ |
| 5784 | if nc.pout > nc.Opts.MaxPingsOut { |
| 5785 | nc.mu.Unlock() |
| 5786 | if shouldClose := nc.processOpErr(ErrStaleConnection, false); shouldClose { |
| 5787 | nc.close(CLOSED, true, nil) |
| 5788 | } |
| 5789 | return |
| 5790 | } |
| 5791 | |
| 5792 | nc.sendPing(nil) |
| 5793 | nc.ptmr.Reset(nc.Opts.PingInterval) |
| 5794 | nc.mu.Unlock() |
| 5795 | } |
| 5796 | |
| 5797 | // FlushTimeout allows a Flush operation to have an associated timeout. |
| 5798 | func (nc *Conn) FlushTimeout(timeout time.Duration) (err error) { |
nothing calls this directly
no test coverage detected