mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkDiscovery via transport.ServerAddress()
This commit is contained in:
parent
0198551cc9
commit
30ce805ae7
@ -59,7 +59,7 @@ protected override ServerResponse ProcessRequest(ServerRequest request, IPEndPoi
|
||||
return new ServerResponse
|
||||
{
|
||||
serverId = ServerId,
|
||||
uri = transport.ServerUri()
|
||||
address = transport.ServerAddress()
|
||||
};
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
@ -98,13 +98,19 @@ protected override void ProcessResponse(ServerResponse response, IPEndPoint endp
|
||||
|
||||
// although we got a supposedly valid url, we may not be able to resolve
|
||||
// the provided host
|
||||
// TODO Y THO???????
|
||||
// However we know the real ip address of the server because we just
|
||||
// received a packet from it, so use that as host.
|
||||
UriBuilder realUri = new UriBuilder(response.uri)
|
||||
// UriBuilder realUri = new UriBuilder(response.uri)
|
||||
// {
|
||||
// Host = response.EndPoint.Address.ToString()
|
||||
// };
|
||||
// response.uri = realUri.Uri;
|
||||
|
||||
if (Utils.ParseHostAndPort(response.address, out string _, out ushort port))
|
||||
{
|
||||
Host = response.EndPoint.Address.ToString()
|
||||
};
|
||||
response.uri = realUri.Uri;
|
||||
response.address = $"{response.EndPoint.Address}:{port}";
|
||||
}
|
||||
|
||||
OnServerFound.Invoke(response);
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
|
||||
namespace Mirror.Discovery
|
||||
{
|
||||
@ -10,7 +9,8 @@ public struct ServerResponse : NetworkMessage
|
||||
// client fills this up after we receive it
|
||||
public IPEndPoint EndPoint { get; set; }
|
||||
|
||||
public Uri uri;
|
||||
// Transport.ServerAddress(). can be "IP:Port".
|
||||
public string address;
|
||||
|
||||
// Prevent duplicate server appearance when a connection can be made via LAN on multiple NICs
|
||||
public long serverId;
|
||||
|
Loading…
Reference in New Issue
Block a user