mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
breaking: clean up Server Disconnect code so it only calls Transport.Disconnect and the future Transport.OnDisconnected call handles the rest.
This commit is contained in:
parent
45e481e65e
commit
04e184dfad
@ -173,12 +173,19 @@ internal void Update()
|
||||
}
|
||||
|
||||
/// <summary>Disconnects this connection.</summary>
|
||||
// IMPORTANT: calls Transport.Disconnect.
|
||||
// Transport.OnDisconnected is then called at some point in the future.
|
||||
public override void Disconnect()
|
||||
{
|
||||
// set not ready and handle clientscene disconnect in any case
|
||||
// (might be client or host mode here)
|
||||
isReady = false;
|
||||
// old UNET disconnect handling:
|
||||
//isReady = false;
|
||||
// NetworkServer.OnTransportDisconnected removes conn so not needed!
|
||||
|
||||
// ask transport to disconnect
|
||||
Transport.activeTransport.ServerDisconnect(connectionId);
|
||||
|
||||
// remove self from observing's observers
|
||||
// TODO move to OnTransportDisconnected?
|
||||
RemoveFromObservingsObservers();
|
||||
}
|
||||
}
|
||||
|
@ -390,6 +390,7 @@ static void OnTransportConnected(int connectionId)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO move this into OnTransportConnected later :/
|
||||
internal static void OnConnected(NetworkConnectionToClient conn)
|
||||
{
|
||||
// Debug.Log("Server accepted client:" + conn);
|
||||
@ -418,7 +419,8 @@ internal static void OnTransportDisconnected(int connectionId)
|
||||
// Debug.Log("Server disconnect client:" + connectionId);
|
||||
if (connections.TryGetValue(connectionId, out NetworkConnectionToClient conn))
|
||||
{
|
||||
conn.Disconnect();
|
||||
// remove connection, call OnDisconnectEvent which is used by
|
||||
// NetworkManager (calls NetworkManager.OnServerDisconnect)
|
||||
RemoveConnection(connectionId);
|
||||
// Debug.Log("Server lost client:" + connectionId);
|
||||
|
||||
@ -532,10 +534,9 @@ public static void DisconnectAllExternalConnections()
|
||||
// copy is no performance problem.
|
||||
foreach (NetworkConnectionToClient conn in connections.Values.ToList())
|
||||
{
|
||||
// simply disconnect.
|
||||
// Transport.OnDisconnected is called later.
|
||||
conn.Disconnect();
|
||||
// call OnDisconnected unless local player in host mode
|
||||
if (conn.connectionId != NetworkConnection.LocalConnectionId)
|
||||
OnDisconnected(conn);
|
||||
}
|
||||
connections.Clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user