当前位置: 首页>>代码示例>>C#>>正文


C# Contact.GetID方法代码示例

本文整理汇总了C#中Contact.GetID方法的典型用法代码示例。如果您正苦于以下问题:C# Contact.GetID方法的具体用法?C# Contact.GetID怎么用?C# Contact.GetID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact.GetID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddContact

        public void AddContact(Contact applicant)
        {
            //Never add myself
            if (applicant.GetID() == myself.GetID())
                return;
            // If we already know about them
            if (Contains(applicant.GetID()))
            {
                // If they have a new address, record that
                if (Get(applicant.GetID()).Uri
                   != applicant.Uri)
                {
                    // Replace old one
                    Remove(applicant.GetID());
                    Put(applicant);
                }
                else
                { // Just promote them
                    Promote(applicant.GetID());
                }
                return;
            }

            // If we can fit them, do so
            Contact blocker = Blocker(applicant.GetID());
            if (blocker == null)
            {
                Put(applicant);
                return;
            }

            //has the blocker been pinged recently?

            // We can't fit them. We have to choose between blocker and applicant
            var remotePeerUri = blocker.ToUri();
            var peer = serverFactory(remotePeerUri);

            // If the blocker doesn't respond, pick the applicant.
            var pingResult = peer.Ping(myself);
            if (pingResult == null)
            {
                Remove(blocker.GetID());
                Put(applicant);
            }
        }
开发者ID:MatthewRobertDunn,项目名称:Chordial,代码行数:45,代码来源:BucketList.cs

示例2: BucketList

        /// <summary>
        /// Make a new bucket list, for holding node contacts.
        /// </summary>
        /// <param name="ourID">The ID to center the list on.</param>
        public BucketList(Contact ourID, Func<Uri, IKadmeliaServer> serverFactory)
        {
            this.ourID = ourID.GetID();
            this.myself = ourID;
            buckets = new List<List<Contact>>(NUM_BUCKETS);
            accessTimes = new List<DateTime>();

            // Set up each bucket
            for (int i = 0; i < NUM_BUCKETS; i++)
            {
                buckets.Add(new List<Contact>(BUCKET_SIZE));
                accessTimes.Add(default(DateTime));
            }
            this.serverFactory = serverFactory;
        }
开发者ID:MatthewRobertDunn,项目名称:Chordial,代码行数:19,代码来源:BucketList.cs

示例3: Put

        public void Put(Contact toAdd)
        {
            if (toAdd == null)
            {
                return; // Don't be silly.
            }

            int bucket = BucketFor(toAdd.GetID());
            buckets[bucket].Add(toAdd); // No lock: people can read while we do this.
            accessTimes[bucket] = DateTime.Now;
        }
开发者ID:MatthewRobertDunn,项目名称:Chordial,代码行数:11,代码来源:BucketList.cs


注:本文中的Contact.GetID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。