Reformat files
This commit is contained in:
parent
644b2f80cc
commit
419ceee24d
|
@ -0,0 +1,4 @@
|
||||||
|
printWidth: 110
|
||||||
|
useTabs: false
|
||||||
|
tabWidth: 4
|
||||||
|
endOfLine: auto
|
|
@ -36,11 +36,7 @@ public class ConfigureNavBar : MonoBehaviour
|
||||||
BoxCollider boxCollider = canvas.GetComponent<BoxCollider>();
|
BoxCollider boxCollider = canvas.GetComponent<BoxCollider>();
|
||||||
if (boxCollider != null)
|
if (boxCollider != null)
|
||||||
{
|
{
|
||||||
boxCollider.size = new Vector3(
|
boxCollider.size = new Vector3(boxCollider.size.x, isVisible ? 400 : 370, boxCollider.size.z);
|
||||||
boxCollider.size.x,
|
|
||||||
isVisible ? 400 : 370,
|
|
||||||
boxCollider.size.z
|
|
||||||
);
|
|
||||||
boxCollider.center = new Vector3(0, isVisible ? 0 : -16, 0);
|
boxCollider.center = new Vector3(0, isVisible ? 0 : -16, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,11 +108,7 @@ public class EndpointLoader : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessEndpointResponse(
|
private void ProcessEndpointResponse(UnityWebRequest request, string endpoint, ref bool loadedFlag)
|
||||||
UnityWebRequest request,
|
|
||||||
string endpoint,
|
|
||||||
ref bool loadedFlag
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
request.result == UnityWebRequest.Result.ConnectionError
|
request.result == UnityWebRequest.Result.ConnectionError
|
||||||
|
|
|
@ -82,11 +82,7 @@ public class ServiceDiscovery : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
udpClient = new UdpClient();
|
udpClient = new UdpClient();
|
||||||
udpClient.Client.SetSocketOption(
|
udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
||||||
SocketOptionLevel.Socket,
|
|
||||||
SocketOptionName.ReuseAddress,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
udpClient.Client.Bind(new IPEndPoint(defaultIP, multicastPort));
|
udpClient.Client.Bind(new IPEndPoint(defaultIP, multicastPort));
|
||||||
udpClient.JoinMulticastGroup(IPAddress.Parse(multicastAddress), defaultIP);
|
udpClient.JoinMulticastGroup(IPAddress.Parse(multicastAddress), defaultIP);
|
||||||
|
|
||||||
|
@ -109,11 +105,7 @@ public class ServiceDiscovery : MonoBehaviour
|
||||||
byte[] query = CreateMdnsQuery(serviceName);
|
byte[] query = CreateMdnsQuery(serviceName);
|
||||||
Debug.Log($"Sending mDNS query for {serviceName}");
|
Debug.Log($"Sending mDNS query for {serviceName}");
|
||||||
|
|
||||||
udpClient.Send(
|
udpClient.Send(query, query.Length, new IPEndPoint(IPAddress.Parse(multicastAddress), multicastPort));
|
||||||
query,
|
|
||||||
query.Length,
|
|
||||||
new IPEndPoint(IPAddress.Parse(multicastAddress), multicastPort)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] CreateMdnsQuery(string serviceName)
|
private byte[] CreateMdnsQuery(string serviceName)
|
||||||
|
@ -186,10 +178,7 @@ public class ServiceDiscovery : MonoBehaviour
|
||||||
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, multicastPort);
|
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, multicastPort);
|
||||||
byte[] receivedBytes = udpClient.EndReceive(result, ref remoteEndPoint);
|
byte[] receivedBytes = udpClient.EndReceive(result, ref remoteEndPoint);
|
||||||
|
|
||||||
ushort flags = BitConverter.ToUInt16(
|
ushort flags = BitConverter.ToUInt16(new byte[] { receivedBytes[3], receivedBytes[2] }, 0);
|
||||||
new byte[] { receivedBytes[3], receivedBytes[2] },
|
|
||||||
0
|
|
||||||
);
|
|
||||||
if (flags == 0x0100)
|
if (flags == 0x0100)
|
||||||
{
|
{
|
||||||
udpClient?.BeginReceive(OnReceive, null);
|
udpClient?.BeginReceive(OnReceive, null);
|
||||||
|
@ -208,12 +197,7 @@ public class ServiceDiscovery : MonoBehaviour
|
||||||
|
|
||||||
private void AddMdnsService()
|
private void AddMdnsService()
|
||||||
{
|
{
|
||||||
if (
|
if (receivedIp != null && receivedPort != null && receivedHost != null && receivedPath != null)
|
||||||
receivedIp != null
|
|
||||||
&& receivedPort != null
|
|
||||||
&& receivedHost != null
|
|
||||||
&& receivedPath != null
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
MdnsService currentService = new MdnsService(
|
MdnsService currentService = new MdnsService(
|
||||||
receivedIp,
|
receivedIp,
|
||||||
|
@ -260,13 +244,10 @@ public class ServiceDiscovery : MonoBehaviour
|
||||||
string name;
|
string name;
|
||||||
(name, offset) = ReadName(data, offset);
|
(name, offset) = ReadName(data, offset);
|
||||||
|
|
||||||
ushort recordType = (ushort)
|
ushort recordType = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset));
|
||||||
IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset));
|
ushort recordClass = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 2));
|
||||||
ushort recordClass = (ushort)
|
|
||||||
IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 2));
|
|
||||||
uint ttl = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data, offset + 4));
|
uint ttl = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data, offset + 4));
|
||||||
ushort dataLength = (ushort)
|
ushort dataLength = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 8));
|
||||||
IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 8));
|
|
||||||
offset += 10;
|
offset += 10;
|
||||||
|
|
||||||
if (ttl == 0)
|
if (ttl == 0)
|
||||||
|
@ -277,9 +258,7 @@ public class ServiceDiscovery : MonoBehaviour
|
||||||
|
|
||||||
if (recordType == 1) // A Record
|
if (recordType == 1) // A Record
|
||||||
{
|
{
|
||||||
IPAddress ipAddress = new IPAddress(
|
IPAddress ipAddress = new IPAddress(new ArraySegment<byte>(data, offset, dataLength).ToArray());
|
||||||
new ArraySegment<byte>(data, offset, dataLength).ToArray()
|
|
||||||
);
|
|
||||||
receivedIp = ipAddress.ToString();
|
receivedIp = ipAddress.ToString();
|
||||||
receivedHost = name;
|
receivedHost = name;
|
||||||
}
|
}
|
||||||
|
@ -290,12 +269,9 @@ public class ServiceDiscovery : MonoBehaviour
|
||||||
}
|
}
|
||||||
else if (recordType == 33) // SRV Record
|
else if (recordType == 33) // SRV Record
|
||||||
{
|
{
|
||||||
ushort priority = (ushort)
|
ushort priority = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset));
|
||||||
IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset));
|
ushort weight = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 2));
|
||||||
ushort weight = (ushort)
|
ushort port = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 4));
|
||||||
IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 2));
|
|
||||||
ushort port = (ushort)
|
|
||||||
IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, offset + 4));
|
|
||||||
string target;
|
string target;
|
||||||
(target, _) = ReadName(data, offset + 6);
|
(target, _) = ReadName(data, offset + 6);
|
||||||
receivedPort = port.ToString();
|
receivedPort = port.ToString();
|
||||||
|
|
Loading…
Reference in New Issue