remove QNetworkServer.localConnections as there is always only 1 connection

This commit is contained in:
JohnCorby 2021-12-20 15:11:31 -08:00
parent ae914b3626
commit 0ad35e08fd
3 changed files with 11 additions and 27 deletions

View File

@ -631,14 +631,12 @@ namespace QuantumUNET.Components
}
}
foreach (var networkConnection2 in QNetworkServer.localConnections)
var networkConnection2 = QNetworkServer.localConnection;
if (networkConnection2 != null)
{
if (networkConnection2 != null)
if (networkConnection2.isReady)
{
if (networkConnection2.isReady)
{
AddObserver(networkConnection2);
}
AddObserver(networkConnection2);
}
}
}
@ -674,12 +672,10 @@ namespace QuantumUNET.Components
if (initialize)
{
foreach (var connection in QNetworkServer.localConnections)
var connection = QNetworkServer.localConnection;
if (!hashSet.Contains(connection))
{
if (!hashSet.Contains(connection))
{
OnSetLocalVisibility(false);
}
OnSetLocalVisibility(false);
}
}

View File

@ -17,7 +17,7 @@ namespace QuantumUNET
}
m_AsyncConnect = ConnectState.Disconnected;
m_LocalServer.RemoveLocalClient(m_Connection);
m_LocalServer.RemoveLocalClient();
}
internal void InternalConnectLocalServer(bool generateConnectMsg)

View File

@ -22,7 +22,7 @@ namespace QuantumUNET
m_SimpleServerSimple = new ServerSimpleWrapper(this);
}
public static List<QNetworkConnection> localConnections => instance.m_LocalConnectionsFakeList;
public static QNetworkConnection localConnection => instance.m_LocalConnection;
public static int listenPort => instance.m_SimpleServerSimple.listenPort;
@ -151,7 +151,7 @@ namespace QuantumUNET
internal int AddLocalClient(QLocalClient localClient)
{
int result;
if (m_LocalConnectionsFakeList.Count != 0)
if (m_LocalConnection != null)
{
QLog.Error("Local Connection already exists");
result = -1;
@ -163,7 +163,6 @@ namespace QuantumUNET
connectionId = 0
};
m_SimpleServerSimple.SetConnectionAtIndex(m_LocalConnection);
m_LocalConnectionsFakeList.Add(m_LocalConnection);
m_LocalConnection.InvokeHandlerNoData(32);
result = 0;
}
@ -171,17 +170,8 @@ namespace QuantumUNET
return result;
}
internal void RemoveLocalClient(QNetworkConnection localClientConnection)
internal void RemoveLocalClient()
{
for (var i = 0; i < m_LocalConnectionsFakeList.Count; i++)
{
if (m_LocalConnectionsFakeList[i].connectionId == localClientConnection.connectionId)
{
m_LocalConnectionsFakeList.RemoveAt(i);
break;
}
}
if (m_LocalConnection != null)
{
m_LocalConnection.Disconnect();
@ -1351,8 +1341,6 @@ namespace QuantumUNET
private bool m_LocalClientActive;
private readonly List<QNetworkConnection> m_LocalConnectionsFakeList = new();
private QULocalConnectionToClient m_LocalConnection;
private readonly QNetworkScene m_NetworkScene;