From f1457467726698405c0b5f94a1598730a7187bf8 Mon Sep 17 00:00:00 2001 From: AeonLucid Date: Mon, 19 Oct 2020 16:26:35 +0200 Subject: [PATCH] Final touches for client --- src/Impostor.Client.App/Program.cs | 6 +++++- src/Impostor.Hazel/Connection.cs | 2 +- src/Impostor.Hazel/Udp/UdpConnection.cs | 2 +- src/Impostor.Server/Net/Hazel/HazelConnection.cs | 2 +- src/Impostor.Server/Net/State/Game.Outgoing.cs | 6 +++--- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Impostor.Client.App/Program.cs b/src/Impostor.Client.App/Program.cs index 4a96f9f..cce1d29 100644 --- a/src/Impostor.Client.App/Program.cs +++ b/src/Impostor.Client.App/Program.cs @@ -47,9 +47,13 @@ namespace Impostor.Client.App Log.Information("Connected."); // Create a game. - await connection.Send(writeGameCreate); + await connection.SendAsync(writeGameCreate); Log.Information("Requested game creation."); + // Recycle. + writeHandshake.Recycle(); + writeGameCreate.Recycle(); + e.WaitOne(); } } diff --git a/src/Impostor.Hazel/Connection.cs b/src/Impostor.Hazel/Connection.cs index 5d8fe55..dec8cfe 100644 --- a/src/Impostor.Hazel/Connection.cs +++ b/src/Impostor.Hazel/Connection.cs @@ -139,7 +139,7 @@ namespace Impostor.Hazel /// general any implementer should aim to always follow the user's request. /// /// - public abstract ValueTask Send(IMessageWriter msg); + public abstract ValueTask SendAsync(IMessageWriter msg); /// /// Sends a number of bytes to the end point of the connection using the specified . diff --git a/src/Impostor.Hazel/Udp/UdpConnection.cs b/src/Impostor.Hazel/Udp/UdpConnection.cs index 851a2d8..7227dba 100644 --- a/src/Impostor.Hazel/Udp/UdpConnection.cs +++ b/src/Impostor.Hazel/Udp/UdpConnection.cs @@ -111,7 +111,7 @@ namespace Impostor.Hazel.Udp protected abstract ValueTask WriteBytesToConnection(byte[] bytes, int length); /// - public override async ValueTask Send(IMessageWriter msg) + public override async ValueTask SendAsync(IMessageWriter msg) { if (this._state != ConnectionState.Connected) throw new InvalidOperationException("Could not send data as this Connection is not connected. Did you disconnect?"); diff --git a/src/Impostor.Server/Net/Hazel/HazelConnection.cs b/src/Impostor.Server/Net/Hazel/HazelConnection.cs index 7b1c15e..a1520b8 100644 --- a/src/Impostor.Server/Net/Hazel/HazelConnection.cs +++ b/src/Impostor.Server/Net/Hazel/HazelConnection.cs @@ -28,7 +28,7 @@ namespace Impostor.Server.Net.Hazel public ValueTask SendAsync(IMessageWriter writer) { - return InnerConnection.Send(writer); + return InnerConnection.SendAsync(writer); } private async ValueTask ConnectionOnDisconnected(DisconnectedEventArgs e) diff --git a/src/Impostor.Server/Net/State/Game.Outgoing.cs b/src/Impostor.Server/Net/State/Game.Outgoing.cs index ddbf2c7..c602ffd 100644 --- a/src/Impostor.Server/Net/State/Game.Outgoing.cs +++ b/src/Impostor.Server/Net/State/Game.Outgoing.cs @@ -14,7 +14,7 @@ namespace Impostor.Server.Net.State { foreach (var connection in GetConnections(x => x.Limbo.HasFlag(states))) { - connection.Send(writer); + connection.SendAsync(writer); } return default; @@ -26,7 +26,7 @@ namespace Impostor.Server.Net.State x.Limbo.HasFlag(states) && x.Client.Id != senderId)) { - connection.Send(writer); + connection.SendAsync(writer); } return default; @@ -36,7 +36,7 @@ namespace Impostor.Server.Net.State { if (TryGetPlayer(id, out var player) && player.Client.Connection is HazelConnection hazelConnection) { - hazelConnection.InnerConnection.Send(writer); + hazelConnection.InnerConnection.SendAsync(writer); } return default; -- 2.39.5