RTT calculates the round trip time between this client and the server.
()
| 5837 | |
| 5838 | // RTT calculates the round trip time between this client and the server. |
| 5839 | func (nc *Conn) RTT() (time.Duration, error) { |
| 5840 | if nc.IsClosed() { |
| 5841 | return 0, ErrConnectionClosed |
| 5842 | } |
| 5843 | if nc.IsReconnecting() { |
| 5844 | return 0, ErrDisconnected |
| 5845 | } |
| 5846 | start := time.Now() |
| 5847 | if err := nc.FlushTimeout(10 * time.Second); err != nil { |
| 5848 | return 0, err |
| 5849 | } |
| 5850 | return time.Since(start), nil |
| 5851 | } |
| 5852 | |
| 5853 | // Flush will perform a round trip to the server and return when it |
| 5854 | // receives the internal reply. |