fix: Stop calling ClientDisconnect on host (#597)

* Stop calling ClientDisconnect on host

* Update NetworkConnection.cs

* Update NetworkServer.cs
This commit is contained in:
MichalPetryka 2019-03-17 19:37:21 +01:00 committed by vis2k
parent 78504533f3
commit b67b3e4304
2 changed files with 9 additions and 14 deletions

View File

@ -82,14 +82,15 @@ public void Disconnect()
isReady = false;
ClientScene.HandleClientDisconnect(this);
// paul: we may be connecting or connected, either way, we need to disconnect
// transport should not do anything if it is not connecting/connected
Transport.activeTransport.ClientDisconnect();
// server? then disconnect that client
if (Transport.activeTransport.ServerActive())
{
Transport.activeTransport.ServerDisconnect(connectionId);
}
// not server and not host mode? then disconnect client
else
{
Transport.activeTransport.ClientDisconnect();
}
// remove observers

View File

@ -289,13 +289,7 @@ public static bool SendToReady<T>(NetworkIdentity identity,T msg, int channelId
public static void DisconnectAll()
{
DisconnectAllConnections();
if (s_LocalConnection != null)
{
s_LocalConnection.Disconnect();
s_LocalConnection.Dispose();
s_LocalConnection = null;
}
s_LocalConnection = null;
active = false;
localClientActive = false;
@ -307,7 +301,9 @@ public static void DisconnectAllConnections()
{
NetworkConnection conn = kvp.Value;
conn.Disconnect();
OnDisconnected(conn);
// call OnDisconnected unless local player in host mode
if (conn.connectionId != 0)
OnDisconnected(conn);
conn.Dispose();
}
connections.Clear();
@ -415,8 +411,6 @@ static void OnDisconnected(NetworkConnection conn)
}
if (LogFilter.Debug) Debug.Log("Server lost client:" + conn.connectionId);
conn.RemoveObservers();
conn.Dispose();
}
static void OnDataReceived(int connectionId, byte[] data)