using System; using System.Collections.Concurrent; using System.Net; namespace Mistox.Client { public class MistoxClient { public string ServerName { get; set; } = ""; // The Name of the server public bool Alive { get; set; } = true; // Is the server running public mTCPClient ServerConnection; public ConcurrentDictionary clientConnections; public MistoxClient(IPEndPoint Server) { Console.WriteLine( "The client is initilized and trying to connect to the server at ip : " + Server.Address ); try { ServerConnection = new mTCPClient( this, Server ); Console.WriteLine( "Connected to the server sucessfully" ); } catch( Exception e ) { Console.WriteLine( "An error has occured with the connection to the server. Error { " ); Console.WriteLine( e.ToString() ); Console.WriteLine( "}" ); } Alive = true; } public event Action onServerConnected; public void InvokeOnServerConnected(){ Alive = true; onServerConnected?.Invoke(); } public event Action onUserConnected; public void InvokeOnUserConnected(mUDPClient ConnectedUser){ onUserConnected?.Invoke(ConnectedUser); } public event Action onDataReceived; public void InvokeOnReceived(dynamic DataPacket){ onDataReceived?.Invoke(DataPacket); } public event Action onUserDisconnected; public void InvokeOnUserDisconnected(mUDPClient DisconnectedUser){ onUserDisconnected?.Invoke(DisconnectedUser); } public event Action onServerDisconnected; public void InvokeOnServerDisconnected(){ Alive = false; onServerDisconnected?.Invoke(); } } }