Ejemplo n.º 1
0
        public Referral[] GetReferrals()
        {
            Referral[] referralArray     = null;
            bool       canShareReferrals = false;

            try
            {
                canShareReferrals = this.config.Resolver.CanShareReferrals;
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(System.ServiceModel.SR.GetString("ResolverException"), exception);
            }
            if (canShareReferrals)
            {
                List <IPeerNeighbor> connectedNeighbors = this.neighborManager.GetConnectedNeighbors();
                int num = Math.Min(this.config.MaxReferrals, connectedNeighbors.Count);
                referralArray = new Referral[num];
                for (int i = 0; i < num; i++)
                {
                    referralArray[i] = new Referral(connectedNeighbors[i].NodeId, connectedNeighbors[i].ListenAddress);
                }
                return(referralArray);
            }
            return(new Referral[0]);
        }
        public Referral[] GetReferrals()
        {
            Fx.Assert(null != config.Resolver, "");

            Referral[] referrals         = null;
            bool       canShareReferrals = false;

            try
            {
                canShareReferrals = config.Resolver.CanShareReferrals;
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(SR.GetString(SR.ResolverException), e);
            }

            if (canShareReferrals)
            {
                List <IPeerNeighbor> neighbors = this.neighborManager.GetConnectedNeighbors();
                int count = Math.Min(this.config.MaxReferrals, neighbors.Count);
                referrals = new Referral[count];
                for (int i = 0; i < count; i++)
                {
                    referrals[i] = new Referral(neighbors[i].NodeId, neighbors[i].ListenAddress);
                }
            }
            else
            {
                referrals = new Referral[0];
            }
            return(referrals);
        }
 public DisconnectInfo(DisconnectReason reason, Referral[] referrals)
 {
     this.body = new DisconnectInfoDC(reason, referrals);
 }
 public DisconnectInfoDC(DisconnectReason reason, Referral[] referrals)
 {
     this.reason = reason;
     this.referrals = referrals;
 }
 public WelcomeInfo(ulong nodeId, Referral[] referrals)
 {
     this.body = new WelcomeInfoDC(nodeId, referrals);
 }
 public WelcomeInfoDC(ulong nodeId, Referral[] referrals)
 {
     this.nodeId = nodeId;
     this.referrals = referrals;
 }
 public RefuseInfo(RefuseReason reason, Referral[] referrals)
 {
     this.body = new RefuseInfoDC(reason, referrals);
 }
 public RefuseInfoDC(RefuseReason reason, Referral[] referrals)
 {
     this.reason = reason;
     this.referrals = referrals;
 }