示例#1
0
        /// <summary>
        /// Creates a new PingRequestResponseListener and sends out a new PingRequest
        /// message to each of the peers that has not yet replied in the VoteReplyList.
        /// </summary>
        public void TimedOut()
        {
            var prrl = new PingRequestResponseListener(networkListener, vote);

            networkListener.RegisterHandler(prrl, PingRequestResponseListener.Timeout);

            foreach (var peer in vote.VoteReplyList)
            {
                if (!peer.Value)
                {
                    var pingRequest = new Message(MessageType.PingRequest)
                    {
                        DataAsString = peer.Key.ToString()
                    };
                    Outbox.SendMessage(pingRequest);
                }
            }
        }
示例#2
0
        /// <summary>
        /// The PRRL timed out.
        /// All peers that did not respond are registered as non-responding, and a new PRRL is created from the peer list
        /// </summary>
        public void TimedOut()
        {
            foreach (var nonRespondingPeer in nonRespondingPeers)
            {
                vote.SetPeerState(nonRespondingPeer.Key, PeerState.MaybeDead);
            }
            if (retries + 1 >= networkStabilityTreshold)
            {
                throw new NotEnoughPeersException(0);
            }

            var prrl = new PingRequestResponseListener(networkListener, vote, retries + 1);

            networkListener.RegisterHandler(prrl, Timeout);

            foreach (var peer in nonRespondingPeers)
            {
                var pingRequest = new Message(MessageType.PingRequest)
                {
                    DataAsString = peer.Key.ToString()
                };
                Outbox.SendMessage(pingRequest);
            }
        }