diff --git a/Mirror/Runtime/NetworkClient.cs b/Mirror/Runtime/NetworkClient.cs index d3ddb256a..4d240a7fd 100644 --- a/Mirror/Runtime/NetworkClient.cs +++ b/Mirror/Runtime/NetworkClient.cs @@ -17,10 +17,8 @@ public class NetworkClient public static bool pauseMessageHandling; - int m_HostPort; - string m_ServerIp = ""; - int m_ServerPort; + ushort m_ServerPort; int m_ClientId = -1; readonly Dictionary m_MessageHandlers = new Dictionary(); @@ -41,24 +39,11 @@ internal void SetHandlers(NetworkConnection conn) } public string serverIp { get { return m_ServerIp; } } - public int serverPort { get { return m_ServerPort; } } + public ushort serverPort { get { return m_ServerPort; } } + public ushort hostPort; public NetworkConnection connection { get { return m_Connection; } } public Dictionary handlers { get { return m_MessageHandlers; } } - public int hostPort - { - get { return m_HostPort; } - set - { - if (value < 0) - throw new ArgumentException("Port must not be a negative number."); - - if (value > 65535) - throw new ArgumentException("Port must not be greater than 65535."); - - m_HostPort = value; - } - } public bool isConnected { get { return connectState == ConnectState.Connected; } } @@ -87,7 +72,7 @@ public NetworkClient(NetworkConnection conn) RegisterSystemHandlers(false); } - public void Connect(string serverIp, int serverPort) + public void Connect(string serverIp, ushort serverPort) { PrepareForConnect(); diff --git a/Mirror/Runtime/NetworkManager.cs b/Mirror/Runtime/NetworkManager.cs index 384c6c09a..56c6ebfb1 100644 --- a/Mirror/Runtime/NetworkManager.cs +++ b/Mirror/Runtime/NetworkManager.cs @@ -17,7 +17,7 @@ public enum PlayerSpawnMethod public class NetworkManager : MonoBehaviour { // configuration - [FormerlySerializedAs("m_NetworkPort")] public int networkPort = 7777; + [FormerlySerializedAs("m_NetworkPort")] public ushort networkPort = 7777; [FormerlySerializedAs("m_ServerBindToIP")] public bool serverBindToIP; [FormerlySerializedAs("m_ServerBindAddress")] public string serverBindAddress = ""; [FormerlySerializedAs("m_NetworkAddress")] public string networkAddress = "localhost"; @@ -232,7 +232,7 @@ internal void RegisterClientMessages(NetworkClient client) } } - public NetworkClient StartClient(int hostPort=0) + public NetworkClient StartClient(ushort hostPort=0) { InitializeSingleton();