1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-06 02:11:06 +09:00
Files
lidgren-network-gen3/Lidgren.Network/NetPeer.Discovery.cs

41 lines
1.1 KiB
C#

using System;
using System.Net;
namespace Lidgren.Network
{
public partial class NetPeer
{
/// <summary>
/// Emit a discovery signal to all hosts on your subnet
/// </summary>
public void DiscoverLocalPeers(int serverPort)
{
NetOutgoingMessage om = CreateMessage(0);
om.m_libType = NetMessageLibraryType.Discovery;
SendUnconnectedLibrary(om, new IPEndPoint(IPAddress.Broadcast, serverPort));
}
/// <summary>
/// Emit a discovery signal to a single known host
/// </summary>
public bool DiscoverKnownPeer(string host, int serverPort)
{
IPAddress address = NetUtility.Resolve(host);
if (address == null)
return false;
return DiscoverKnownPeer(new IPEndPoint(address, serverPort));
}
/// <summary>
/// Emit a discovery signal to a single known host
/// </summary>
public bool DiscoverKnownPeer(IPEndPoint endpoint)
{
NetOutgoingMessage om = CreateMessage(0);
om.m_libType = NetMessageLibraryType.Discovery;
SendUnconnectedLibrary(om, endpoint);
return true;
}
}
}