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