mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Fix client reconnect
This commit is contained in:
@@ -74,7 +74,7 @@ namespace Robust.Client
|
||||
{
|
||||
if (RunLevel == ClientRunLevel.Connecting)
|
||||
{
|
||||
_net.Shutdown("Client mashing that connect button.");
|
||||
_net.Reset("Client mashing that connect button.");
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,5 +40,7 @@ namespace Robust.Shared.Network
|
||||
/// </summary>
|
||||
/// <param name="reason">The reason why disconnect was called.</param>
|
||||
void ClientDisconnect(string reason);
|
||||
|
||||
void Reset(string reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,11 +375,12 @@ namespace Robust.Shared.Network
|
||||
InitUpnp();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Shutdown(string reason)
|
||||
public void Reset(string reason)
|
||||
{
|
||||
foreach (var kvChannel in _channels)
|
||||
{
|
||||
DisconnectChannel(kvChannel.Value, reason);
|
||||
}
|
||||
|
||||
// request shutdown of the netPeer
|
||||
_netPeers.ForEach(p => p.Peer.Shutdown(reason));
|
||||
@@ -398,10 +399,22 @@ namespace Robust.Shared.Network
|
||||
|
||||
// Clear cached message functions.
|
||||
Array.Clear(_netMsgFunctions, 0, _netMsgFunctions.Length);
|
||||
_blankNetMsgFunctions.Clear();
|
||||
|
||||
// Clear string table.
|
||||
// This has to be done AFTER clearing _netMsgFunctions so that it re-initializes NetMsg 0.
|
||||
_strings.Reset();
|
||||
|
||||
_cancelConnectTokenSource?.Cancel();
|
||||
ClientConnectState = ClientConnectionState.NotConnecting;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Shutdown(string reason)
|
||||
{
|
||||
Reset(reason);
|
||||
|
||||
_blankNetMsgFunctions.Clear();
|
||||
|
||||
_messages.Clear();
|
||||
|
||||
_config.UnsubValueChanged(CVars.NetVerbose, NetVerboseChanged);
|
||||
@@ -418,9 +431,6 @@ namespace Robust.Shared.Network
|
||||
|
||||
_serializer.ClientHandshakeComplete -= OnSerializerOnClientHandshakeComplete;
|
||||
|
||||
_cancelConnectTokenSource?.Cancel();
|
||||
ClientConnectState = ClientConnectionState.NotConnecting;
|
||||
|
||||
ConnectFailed = null;
|
||||
Connected = null;
|
||||
Disconnect = null;
|
||||
@@ -555,7 +565,7 @@ namespace Robust.Shared.Network
|
||||
Disconnect?.Invoke(this, new NetDisconnectedArgs(ServerChannel, reason));
|
||||
}
|
||||
|
||||
Shutdown(reason);
|
||||
Reset(reason);
|
||||
}
|
||||
|
||||
private NetPeerConfiguration _getBaseNetPeerConfig()
|
||||
|
||||
@@ -82,6 +82,11 @@ namespace Robust.UnitTesting
|
||||
}
|
||||
|
||||
public void Shutdown(string reason)
|
||||
{
|
||||
Reset(reason);
|
||||
}
|
||||
|
||||
public void Reset(string reason)
|
||||
{
|
||||
foreach (var channel in _channels.Values.ToList())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user