Skip to content

Commit 82d09dc

Browse files
Clean up using directives
1 parent 8d23970 commit 82d09dc

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
using Unity.Networking.Transport.TLS;
1717
using Unity.Networking.Transport.Utilities;
1818
using UnityEngine;
19-
using NetcodeNetworkEvent = Unity.Netcode.NetworkEvent;
20-
using TransportNetworkEvent = Unity.Networking.Transport.NetworkEvent;
19+
20+
using NetcodeEvent = Unity.Netcode.NetworkEvent;
21+
using TransportError = Unity.Networking.Transport.Error.StatusCode;
22+
using TransportEvent = Unity.Networking.Transport.NetworkEvent.Type;
2123

2224
namespace Unity.Netcode.Transports.UTP
2325
{
@@ -60,7 +62,7 @@ public static class ErrorUtilities
6062
/// <param name="error">UTP error code.</param>
6163
/// <param name="connectionId">ID of the connection on which the error occurred.</param>
6264
/// <returns>Human-readable error message.</returns>
63-
public static string ErrorToString(Networking.Transport.Error.StatusCode error, ulong connectionId)
65+
public static string ErrorToString(TransportError error, ulong connectionId)
6466
{
6567
return ErrorToString((int)error, connectionId);
6668
}
@@ -72,19 +74,19 @@ internal static string ErrorToString(int error, ulong connectionId)
7274

7375
internal static FixedString128Bytes ErrorToFixedString(int error, ulong connectionId)
7476
{
75-
switch ((Networking.Transport.Error.StatusCode)error)
77+
switch ((TransportError)error)
7678
{
77-
case Networking.Transport.Error.StatusCode.Success:
79+
case TransportError.Success:
7880
return k_NetworkSuccess;
79-
case Networking.Transport.Error.StatusCode.NetworkIdMismatch:
81+
case TransportError.NetworkIdMismatch:
8082
return FixedString.Format(k_NetworkIdMismatch, connectionId);
81-
case Networking.Transport.Error.StatusCode.NetworkVersionMismatch:
83+
case TransportError.NetworkVersionMismatch:
8284
return FixedString.Format(k_NetworkVersionMismatch, connectionId);
83-
case Networking.Transport.Error.StatusCode.NetworkStateMismatch:
85+
case TransportError.NetworkStateMismatch:
8486
return FixedString.Format(k_NetworkStateMismatch, connectionId);
85-
case Networking.Transport.Error.StatusCode.NetworkPacketOverflow:
87+
case TransportError.NetworkPacketOverflow:
8688
return k_NetworkPacketOverflow;
87-
case Networking.Transport.Error.StatusCode.NetworkSendQueueFull:
89+
case TransportError.NetworkSendQueueFull:
8890
return k_NetworkSendQueueFull;
8991
default:
9092
return FixedString.Format("Unknown error code {0}.", error);
@@ -765,7 +767,7 @@ public void Execute()
765767
while (!Queue.IsEmpty)
766768
{
767769
var result = Driver.BeginSend(pipeline, connection, out var writer);
768-
if (result != (int)Networking.Transport.Error.StatusCode.Success)
770+
if (result != (int)TransportError.Success)
769771
{
770772
Debug.LogError($"Error sending message: {ErrorUtilities.ErrorToFixedString(result, clientId)}");
771773
return;
@@ -792,7 +794,7 @@ public void Execute()
792794
// and we'll retry sending them later). Otherwise log the error and remove the
793795
// message from the queue (we don't want to resend it again since we'll likely
794796
// just get the same error again).
795-
if (result != (int)Networking.Transport.Error.StatusCode.NetworkSendQueueFull)
797+
if (result != (int)TransportError.NetworkSendQueueFull)
796798
{
797799
Debug.LogError($"Error sending the message: {ErrorUtilities.ErrorToFixedString(result, clientId)}");
798800
Queue.Consume(written);
@@ -838,7 +840,7 @@ private bool AcceptConnection()
838840
return false;
839841
}
840842

841-
InvokeOnTransportEvent(NetcodeNetworkEvent.Connect,
843+
InvokeOnTransportEvent(NetcodeEvent.Connect,
842844
ParseClientId(connection),
843845
default,
844846
m_RealTimeProvider.RealTimeSinceStartup);
@@ -876,7 +878,7 @@ private void ReceiveMessages(ulong clientId, NetworkPipeline pipeline, DataStrea
876878
break;
877879
}
878880

879-
InvokeOnTransportEvent(NetcodeNetworkEvent.Data, clientId, message, m_RealTimeProvider.RealTimeSinceStartup);
881+
InvokeOnTransportEvent(NetcodeEvent.Data, clientId, message, m_RealTimeProvider.RealTimeSinceStartup);
880882
}
881883
}
882884

@@ -887,17 +889,17 @@ private bool ProcessEvent()
887889

888890
switch (eventType)
889891
{
890-
case TransportNetworkEvent.Type.Connect:
892+
case TransportEvent.Connect:
891893
{
892-
InvokeOnTransportEvent(NetcodeNetworkEvent.Connect,
894+
InvokeOnTransportEvent(NetcodeEvent.Connect,
893895
clientId,
894896
default,
895897
m_RealTimeProvider.RealTimeSinceStartup);
896898

897899
m_ServerClientId = clientId;
898900
return true;
899901
}
900-
case TransportNetworkEvent.Type.Disconnect:
902+
case TransportEvent.Disconnect:
901903
{
902904
// If we're a client and had not yet set the server client ID, it means
903905
// our connection to the server failed to be established. Any other case
@@ -911,14 +913,14 @@ private bool ProcessEvent()
911913
m_ReliableReceiveQueues.Remove(clientId);
912914
ClearSendQueuesForClientId(clientId);
913915

914-
InvokeOnTransportEvent(NetcodeNetworkEvent.Disconnect,
916+
InvokeOnTransportEvent(NetcodeEvent.Disconnect,
915917
clientId,
916918
default,
917919
m_RealTimeProvider.RealTimeSinceStartup);
918920

919921
return true;
920922
}
921-
case TransportNetworkEvent.Type.Data:
923+
case TransportEvent.Data:
922924
{
923925
ReceiveMessages(clientId, pipeline, reader);
924926
return true;
@@ -940,7 +942,7 @@ protected override void OnEarlyUpdate()
940942
Debug.LogError("Transport failure! Relay allocation needs to be recreated, and NetworkManager restarted. " +
941943
"Use NetworkManager.OnTransportFailure to be notified of such events programmatically.");
942944

943-
InvokeOnTransportEvent(NetcodeNetworkEvent.TransportFailure, 0, default, m_RealTimeProvider.RealTimeSinceStartup);
945+
InvokeOnTransportEvent(NetcodeEvent.TransportFailure, 0, default, m_RealTimeProvider.RealTimeSinceStartup);
944946
return;
945947
}
946948

@@ -1177,7 +1179,7 @@ public override void DisconnectLocalClient()
11771179
// If we successfully disconnect we dispatch a local disconnect message
11781180
// this how uNET and other transports worked and so this is just keeping with the old behavior
11791181
// should be also noted on the client this will call shutdown on the NetworkManager and the Transport
1180-
InvokeOnTransportEvent(NetcodeNetworkEvent.Disconnect,
1182+
InvokeOnTransportEvent(NetcodeEvent.Disconnect,
11811183
m_ServerClientId,
11821184
default,
11831185
m_RealTimeProvider.RealTimeSinceStartup);
@@ -1314,12 +1316,12 @@ public override void Initialize(NetworkManager networkManager = null)
13141316
/// <param name="payload">The incoming data payload</param>
13151317
/// <param name="receiveTime">The time the event was received, as reported by m_RealTimeProvider.RealTimeSinceStartup.</param>
13161318
/// <returns>Returns the event type</returns>
1317-
public override NetcodeNetworkEvent PollEvent(out ulong clientId, out ArraySegment<byte> payload, out float receiveTime)
1319+
public override NetcodeEvent PollEvent(out ulong clientId, out ArraySegment<byte> payload, out float receiveTime)
13181320
{
13191321
clientId = default;
13201322
payload = default;
13211323
receiveTime = default;
1322-
return NetcodeNetworkEvent.Nothing;
1324+
return NetcodeEvent.Nothing;
13231325
}
13241326

13251327
/// <summary>
@@ -1382,7 +1384,7 @@ public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDel
13821384
DisconnectRemoteClient(clientId);
13831385

13841386
// DisconnectRemoteClient doesn't notify SDK of disconnection.
1385-
InvokeOnTransportEvent(NetcodeNetworkEvent.Disconnect,
1387+
InvokeOnTransportEvent(NetcodeEvent.Disconnect,
13861388
clientId,
13871389
default(ArraySegment<byte>),
13881390
m_RealTimeProvider.RealTimeSinceStartup);

0 commit comments

Comments
 (0)