public static SendPing ( IOutgoingSocket socket, ushort sequence ) : bool | ||
socket | IOutgoingSocket | |
sequence | ushort | |
리턴 | bool |
/// <summary> /// We do this once a second: /// - if peer has gone quiet, send TCP ping and emit EVASIVE event /// - if peer has disappeared, expire it /// </summary> /// <param name="peer">the peer to ping</param> /// <returns>true if this peer should be removed</returns> private bool PingPeer(ZyrePeer peer) { if (!_isRunning) { // We have been stopped. We know longer can communicate to peers. return(true); } if (DateTime.Now >= peer.ExpiredAt) { return(true); } if (DateTime.Now >= peer.EvasiveAt) { // If peer is being evasive, force a TCP ping. // ZeroMQTODO: do this only once for a peer in this state; // it would be nicer to use a proper state machine // for peer management. _loggerDelegate?.Invoke($"Peer seems dead/slow: name={peer.Name} endpoint={peer.Endpoint}"); ZreMsg.SendPing(_outbox, 0); // Inform the calling application this peer is being evasive _outbox.SendMoreFrame("EVASIVE"); _outbox.SendMoreFrame(peer.Uuid.ToByteArray()); _outbox.SendFrame(peer.Name); } return(false); }