Engine-Pong/Game/Network/NetworkClient.cs

22 lines
552 B
C#

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();
}