From 977a2abdd7402d607769f4b5da01d5e9eb26fd60 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Thu, 1 Feb 2024 23:38:35 +0300 Subject: [PATCH] feat: NetworkClient --- Game/Network/NetworkClient.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Game/Network/NetworkClient.cs diff --git a/Game/Network/NetworkClient.cs b/Game/Network/NetworkClient.cs new file mode 100644 index 0000000..39e617a --- /dev/null +++ b/Game/Network/NetworkClient.cs @@ -0,0 +1,21 @@ +using LiteNetLib; + +namespace Game.Network; + +public class NetworkClient +{ + public readonly EventBasedNetListener Listener = null!; + public readonly NetManager Client = null!; + + public NetworkClient() + { + Listener = new EventBasedNetListener(); + Client = new NetManager(Listener); + } + + public void Connect(string address, int port, string? password = null) + => Client.Connect(address, port, password ?? string.Empty); + + public void PollEvents() => Client.PollEvents(); + public void Stop() => Client.Stop(); +}