Fix exceptions from netchannel disconnecting during handshake.

This commit is contained in:
Pieter-Jan Briers
2020-08-16 02:19:57 +02:00
parent 5637669876
commit 562901e8e7
2 changed files with 11 additions and 4 deletions

View File

@@ -66,10 +66,14 @@ namespace Robust.Server.GameStates
private void HandleClientDisconnect(object? sender, NetChannelArgs e)
{
_entityManager.DropPlayerState(_playerManager.GetSessionById(e.Channel.SessionId));
_ackedStates.Remove(e.Channel.ConnectionId);
if (_ackedStates.ContainsKey(e.Channel.ConnectionId))
_ackedStates.Remove(e.Channel.ConnectionId);
if (!_playerManager.TryGetSessionByChannel(e.Channel, out var session))
{
return;
}
_entityManager.DropPlayerState(session);
}
private void HandleStateAck(MsgStateAck msg)

View File

@@ -344,7 +344,10 @@ namespace Robust.Server.Player
/// </summary>
private void EndSession(object? sender, NetChannelArgs args)
{
var session = GetSessionByChannel(args.Channel);
if (!TryGetSessionByChannel(args.Channel, out var session))
{
return;
}
// make sure nothing got messed up during the life of the session
DebugTools.Assert(session.ConnectedClient == args.Channel);