18 public LidgrenEndpoint(IPAddress address,
int port) : this(new IPEndPoint(address, port)) { }
22 NetEndpoint =
new IPEndPoint((
Address as LidgrenAddress)!.NetAddress, netEndpoint.Port);
25 public new static Option<LidgrenEndpoint>
Parse(
string endpointStr)
32 string hostName = endpointStr;
33 int port = NetConfig.DefaultPort;
34 if (endpointStr.Count(c => c ==
':') == 1)
36 string[] split = endpointStr.Split(
':');
38 port =
int.TryParse(split[1], out var tmpPort) ? tmpPort : port;
41 if (LidgrenAddress.Parse(hostName).TryUnwrap(out var adr) ||
42 (tryParseHostName && LidgrenAddress.ParseHostName(hostName).TryUnwrap(out adr)))
44 return Option<LidgrenEndpoint>.Some(
new LidgrenEndpoint(adr.NetAddress, port));
47 return IPEndPoint.TryParse(endpointStr, out IPEndPoint? netEndpoint)
49 : Option<LidgrenEndpoint>.None();
52 public override bool Equals(
object? obj)
63 => a.NetEndpoint.EquivalentTo(b.NetEndpoint);
LidgrenEndpoint(IPAddress address, int port)
override string StringRepresentation
static bool operator!=(LidgrenEndpoint a, LidgrenEndpoint b)
static bool operator==(LidgrenEndpoint a, LidgrenEndpoint b)
static new Option< LidgrenEndpoint > Parse(string endpointStr)
override int GetHashCode()
LidgrenEndpoint(IPEndPoint netEndpoint)
readonly IPEndPoint NetEndpoint
override bool Equals(object? obj)
override LocalizedString ServerTypeString
static Option< LidgrenEndpoint > ParseFromWithHostNameCheck(string endpointStr, bool tryParseHostName)