diff --git a/server/src/Vanguard.Server/Matches/MatchGrain.cs b/server/src/Vanguard.Server/Matches/MatchGrain.cs index 0eac1eb..ed7bff5 100644 --- a/server/src/Vanguard.Server/Matches/MatchGrain.cs +++ b/server/src/Vanguard.Server/Matches/MatchGrain.cs @@ -201,7 +201,19 @@ public sealed class MatchGrain : IMatchGrain IMatchConnection connection, long resumeFromSeq) { - _connections.Register(_matchId, seat, connection); + var previous = _connections.Register(_matchId, seat, connection); + if (previous is not null && !ReferenceEquals(previous, connection)) + { + try + { + await previous.CloseAsync(4409, "replaced"); + } + catch (Exception exception) + { + _logger.LogDebug(exception, "Match {MatchId}: closing old connection failed.", _matchId); + } + } + var attached = await AttachAsync(seat, playerId, resumeFromSeq); if (!attached) diff --git a/server/tests/Vanguard.Server.Tests/OrleansMatchTests.cs b/server/tests/Vanguard.Server.Tests/OrleansMatchTests.cs index 5e94cf0..b8c0184 100644 --- a/server/tests/Vanguard.Server.Tests/OrleansMatchTests.cs +++ b/server/tests/Vanguard.Server.Tests/OrleansMatchTests.cs @@ -95,6 +95,13 @@ public class OrleansMatchTests public void Configure(ISiloBuilder siloBuilder) { + siloBuilder.ConfigureLogging(logging => + { + logging.ClearProviders(); + logging.AddConsole(); + logging.SetMinimumLevel(LogLevel.Debug); + }); + siloBuilder.ConfigureServices(services => { var options = ServerTestData.SmallOptions();