本文整理汇总了C#中System.Net.PeerToPeer.Collaboration.PeerCollaboration.GetPeersNearMe方法的典型用法代码示例。如果您正苦于以下问题:C# PeerCollaboration.GetPeersNearMe方法的具体用法?C# PeerCollaboration.GetPeersNearMe怎么用?C# PeerCollaboration.GetPeersNearMe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了PeerCollaboration.GetPeersNearMe方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPeersNearMe
//This function retrieves the peers near me as a PeerNearMeCollection.
public static PeerNearMeCollection GetPeersNearMe()
{
PeerNearMeCollection peers = null;
try
{
peers = PeerCollaboration.GetPeersNearMe();
if (peers == null ||
peers.Count == 0)
{
Console.WriteLine("There are no peers near me.");
}
foreach (PeerNearMe pnm in peers)
{
Console.WriteLine("Getting the peers near me: {0}, nickname {1}, isOnline {2}",
pnm.ToString(),
pnm.Nickname,
pnm.IsOnline);
}
}
catch (PeerToPeerException p2pEx)
{
Console.WriteLine("Could not obtain an enumeration of the peers near me: {0}", p2pEx.Message);
}
catch (InvalidOperationException ioEx)
{
Console.WriteLine("The application is no longer signed into the Peer Collaboration Infrastructure: {0}",
ioEx.Message);
}
catch (Exception ex)
{
Console.WriteLine("Unexpected exception caught when trying to enumerate the peers near me: {0}",
ex.Message);
}
return peers;
}
开发者ID:.NET开发者,项目名称:System.Net.PeerToPeer.Collaboration,代码行数:37,代码来源:PeerCollaboration.GetPeersNearMe