NetworkManager.StartHost/StartServer use m_MaxConnections instead of extra parameter, because that's what it's for. NetworkServer.Listen has maxConnections parameter now.

This commit is contained in:
vis2k 2018-08-20 10:31:04 +02:00
parent b904220aa2
commit f104699784
2 changed files with 8 additions and 26 deletions

View File

@ -216,11 +216,6 @@ internal void RegisterServerMessages()
} }
public bool StartServer() public bool StartServer()
{
return StartServer(-1);
}
bool StartServer(int maxConnections)
{ {
InitializeSingleton(); InitializeSingleton();
@ -233,7 +228,7 @@ bool StartServer(int maxConnections)
if (m_ServerBindToIP && !string.IsNullOrEmpty(m_ServerBindAddress)) 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."); } if (LogFilter.logError) { Debug.LogError("StartServer listen on " + m_ServerBindAddress + " failed."); }
return false; return false;
@ -241,7 +236,7 @@ bool StartServer(int maxConnections)
} }
else else
{ {
if (!NetworkServer.Listen(m_NetworkPort)) if (!NetworkServer.Listen(m_NetworkPort, m_MaxConnections))
{ {
if (LogFilter.logError) { Debug.LogError("StartServer listen failed."); } if (LogFilter.logError) { Debug.LogError("StartServer listen failed."); }
return false; return false;
@ -345,19 +340,6 @@ public NetworkClient StartClient(int hostPort=0)
return client; 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() public virtual NetworkClient StartHost()
{ {
OnStartHost(); OnStartHost();

View File

@ -101,17 +101,17 @@ static internal void RegisterMessageHandlers()
RegisterHandler((short)MsgType.AnimationTrigger, NetworkAnimator.OnAnimationTriggerServerMessage); 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(); Initialize();
@ -130,7 +130,7 @@ static internal bool InternalListen(string ipAddress, int serverPort)
else else
{ {
Debug.Log("NetworkServer.InternalListen calls NetworkTransport.AddHost port=" + serverPort); 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 s_ServerHostId = 0; // so it doesn't return false
} }