From f1046997843585bad47494fbf111c64ad975df3d Mon Sep 17 00:00:00 2001 From: vis2k Date: Mon, 20 Aug 2018 10:31:04 +0200 Subject: [PATCH] NetworkManager.StartHost/StartServer use m_MaxConnections instead of extra parameter, because that's what it's for. NetworkServer.Listen has maxConnections parameter now. --- .../Runtime/NetworkManager.cs | 22 ++----------------- .../Runtime/NetworkServer.cs | 12 +++++----- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/Unity-Technologies-networking/Runtime/NetworkManager.cs b/Unity-Technologies-networking/Runtime/NetworkManager.cs index 4193df158..b20a9c273 100644 --- a/Unity-Technologies-networking/Runtime/NetworkManager.cs +++ b/Unity-Technologies-networking/Runtime/NetworkManager.cs @@ -216,11 +216,6 @@ internal void RegisterServerMessages() } public bool StartServer() - { - return StartServer(-1); - } - - bool StartServer(int maxConnections) { InitializeSingleton(); @@ -233,7 +228,7 @@ bool StartServer(int maxConnections) if (m_ServerBindToIP && !string.IsNullOrEmpty(m_ServerBindAddress)) { - if (!NetworkServer.Listen(m_ServerBindAddress, m_NetworkPort)) + if (!NetworkServer.Listen(m_ServerBindAddress, m_NetworkPort, m_MaxConnections)) { if (LogFilter.logError) { Debug.LogError("StartServer listen on " + m_ServerBindAddress + " failed."); } return false; @@ -241,7 +236,7 @@ bool StartServer(int maxConnections) } else { - if (!NetworkServer.Listen(m_NetworkPort)) + if (!NetworkServer.Listen(m_NetworkPort, m_MaxConnections)) { if (LogFilter.logError) { Debug.LogError("StartServer listen failed."); } return false; @@ -345,19 +340,6 @@ public NetworkClient StartClient(int hostPort=0) return client; } - public virtual NetworkClient StartHost(int maxConnections) - { - OnStartHost(); - if (StartServer(maxConnections)) - { - var client = ConnectLocalClient(); - OnServerConnect(client.connection); - OnStartClient(client); - return client; - } - return null; - } - public virtual NetworkClient StartHost() { OnStartHost(); diff --git a/Unity-Technologies-networking/Runtime/NetworkServer.cs b/Unity-Technologies-networking/Runtime/NetworkServer.cs index 269ee3581..c3b663da1 100644 --- a/Unity-Technologies-networking/Runtime/NetworkServer.cs +++ b/Unity-Technologies-networking/Runtime/NetworkServer.cs @@ -101,17 +101,17 @@ static internal void RegisterMessageHandlers() RegisterHandler((short)MsgType.AnimationTrigger, NetworkAnimator.OnAnimationTriggerServerMessage); } - static public bool Listen(int serverPort) + static public bool Listen(int serverPort, int maxConnections) { - return InternalListen(null, serverPort); + return InternalListen(null, serverPort, maxConnections); } - static public bool Listen(string ipAddress, int serverPort) + static public bool Listen(string ipAddress, int serverPort, int maxConnections) { - return InternalListen(ipAddress, serverPort); + return InternalListen(ipAddress, serverPort, maxConnections); } - static internal bool InternalListen(string ipAddress, int serverPort) + static internal bool InternalListen(string ipAddress, int serverPort, int maxConnections) { Initialize(); @@ -130,7 +130,7 @@ static internal bool InternalListen(string ipAddress, int serverPort) else { Debug.Log("NetworkServer.InternalListen calls NetworkTransport.AddHost port=" + serverPort); - Transport.server.Start(serverPort); + Transport.server.Start(serverPort, maxConnections); s_ServerHostId = 0; // so it doesn't return false }