本文整理汇总了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);
}
}
示例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;
}
示例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;
}