summaryrefslogtreecommitdiff
path: root/Impostor-dev/src/Impostor.Client.App/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Impostor-dev/src/Impostor.Client.App/Program.cs')
-rw-r--r--Impostor-dev/src/Impostor.Client.App/Program.cs75
1 files changed, 75 insertions, 0 deletions
diff --git a/Impostor-dev/src/Impostor.Client.App/Program.cs b/Impostor-dev/src/Impostor.Client.App/Program.cs
new file mode 100644
index 0000000..aa8866a
--- /dev/null
+++ b/Impostor-dev/src/Impostor.Client.App/Program.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Net;
+using System.Threading;
+using System.Threading.Tasks;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Net.Messages;
+using Impostor.Api.Net.Messages.C2S;
+using Impostor.Hazel;
+using Impostor.Hazel.Udp;
+using Serilog;
+
+namespace Impostor.Client.App
+{
+ internal static class Program
+ {
+ private static readonly ManualResetEvent QuitEvent = new ManualResetEvent(false);
+
+ private static async Task Main(string[] args)
+ {
+ Log.Logger = new LoggerConfiguration()
+ .WriteTo.Console()
+ .CreateLogger();
+
+ var writeHandshake = MessageWriter.Get(MessageType.Reliable);
+
+ writeHandshake.Write(50516550);
+ writeHandshake.Write("AeonLucid");
+
+ var writeGameCreate = MessageWriter.Get(MessageType.Reliable);
+
+ Message00HostGameC2S.Serialize(writeGameCreate, new GameOptionsData
+ {
+ MaxPlayers = 4,
+ NumImpostors = 2
+ });
+
+ // TODO: ObjectPool for MessageReaders
+ using (var connection = new UdpClientConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 22023), null))
+ {
+ var e = new ManualResetEvent(false);
+
+ // Register events.
+ connection.DataReceived = DataReceived;
+ connection.Disconnected = Disconnected;
+
+ // Connect and send handshake.
+ await connection.ConnectAsync(writeHandshake.ToByteArray(false));
+ Log.Information("Connected.");
+
+ // Create a game.
+ await connection.SendAsync(writeGameCreate);
+ Log.Information("Requested game creation.");
+
+ // Recycle.
+ writeHandshake.Recycle();
+ writeGameCreate.Recycle();
+
+ e.WaitOne();
+ }
+ }
+
+ private static ValueTask DataReceived(DataReceivedEventArgs e)
+ {
+ Log.Information("Received data.");
+ return default;
+ }
+
+ private static ValueTask Disconnected(DisconnectedEventArgs e)
+ {
+ Log.Information("Disconnected: " + e.Reason);
+ QuitEvent.Set();
+ return default;
+ }
+ }
+}