Fix leaking MessageWriters

This commit is contained in:
AeonLucid committed 2020-11-12 04:34:07 +01:00
1 parent 2ea270d577
commit 62aa0ff832
3 files changed
+9 -7

No files matched your search

@@ -14,10 +14,12 @@ namespace Impostor.Server.Net.Inner.Objects.Components
SnapTo(position, minSid);
// Broadcast to all clients.
var writer = _game.StartRpc(NetId, RpcCalls.SnapTo);
WriteVector2(writer, position);
writer.Write(_lastSequenceId);
await _game.FinishRpcAsync(writer);
using (var writer = _game.StartRpc(NetId, RpcCalls.SnapTo))
{
WriteVector2(writer, position);
writer.Write(_lastSequenceId);
await _game.FinishRpcAsync(writer);
}
}
}
}
@@ -99,7 +99,7 @@ namespace Impostor.Server.Net.Inner.Objects
public async ValueTask SetMurderedAsync()
{
var writer = _game.StartRpc(NetId, RpcCalls.MurderPlayer);
using var writer = _game.StartRpc(NetId, RpcCalls.MurderPlayer);
writer.Write((byte)NetId);
await _game.FinishRpcAsync(writer);
}
+2 -2
View File
@@ -16,7 +16,7 @@ using Microsoft.Extensions.Logging;
namespace Impostor.Server.Net.State
{
internal partial class Game : IGame
internal partial class Game
{
private readonly ILogger<Game> _logger;
private readonly IServiceProvider _serviceProvider;
@@ -123,4 +123,4 @@ namespace Impostor.Server.Net.State
.Select(p => p.Client.Connection);
}
}
}
}