fix: NetworkDiscovery BroadcastAddress exposed for iOS support (#3255)

* exposing BroadCasting Address 

iOS build prevents broadcasting to 0.0.0.0, so we needed to expose it to change it for our built

* Update NetworkDiscoveryBase.cs

Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
This commit is contained in:
MikiBordils 2022-10-31 22:12:45 +01:00 committed by GitHub
parent 33e0bea844
commit fb95c411ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,10 @@ public abstract class NetworkDiscoveryBase<Request, Response> : MonoBehaviour
[Range(1, 60)] [Range(1, 60)]
float ActiveDiscoveryInterval = 3; float ActiveDiscoveryInterval = 3;
// broadcast address needs to be configurable on iOS:
// https://github.com/vis2k/Mirror/pull/3255
public string BroadcastAddress = "";
protected UdpClient serverUdpClient; protected UdpClient serverUdpClient;
protected UdpClient clientUdpClient; protected UdpClient clientUdpClient;
@ -369,6 +373,18 @@ public void BroadcastDiscoveryRequest()
IPEndPoint endPoint = new IPEndPoint(IPAddress.Broadcast, serverBroadcastListenPort); IPEndPoint endPoint = new IPEndPoint(IPAddress.Broadcast, serverBroadcastListenPort);
if (!string.IsNullOrWhiteSpace(BroadcastAddress))
{
try
{
endPoint = new IPEndPoint(IPAddress.Parse(BroadcastAddress), serverBroadcastListenPort);
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
using (NetworkWriterPooled writer = NetworkWriterPool.Get()) using (NetworkWriterPooled writer = NetworkWriterPool.Get())
{ {
writer.WriteLong(secretHandshake); writer.WriteLong(secretHandshake);