Wire up the event handlers
This commit is contained in:
1 parent
a04516c470
commit
a689f2656f
11 files changed
+90
-76
No files matched your search
@@ -3,21 +3,37 @@
|
||||
namespace Mistox.Client {
|
||||
|
||||
public class MistoxServerClient {
|
||||
|
||||
public string ServerName { get; set; } = ""; // The Name of the server
|
||||
public bool Alive { get; set; } = true; // Is the server running
|
||||
public int Port { get; set; } = 9126; // What Port to bind on
|
||||
|
||||
public event EventHandler onUserConnected;
|
||||
|
||||
public event Action onServerConnected;
|
||||
public void InvokeOnServerConnected(){
|
||||
Alive = true;
|
||||
onServerConnected?.Invoke();
|
||||
}
|
||||
|
||||
public event Action<UDPEndpoint> onUserConnected;
|
||||
public void InvokeOnUserConnected(UDPEndpoint ConnectedUser){
|
||||
onUserConnected?.Invoke(ConnectedUser, new EventArgs());
|
||||
onUserConnected?.Invoke(ConnectedUser);
|
||||
}
|
||||
public event EventHandler onReceived;
|
||||
|
||||
public event Action<dynamic> onDataReceived;
|
||||
public void InvokeOnReceived(dynamic DataPacket){
|
||||
onReceived?.Invoke(DataPacket, new EventArgs());
|
||||
onDataReceived?.Invoke(DataPacket);
|
||||
}
|
||||
public event EventHandler onUserDisconnected;
|
||||
|
||||
public event Action<UDPEndpoint> onUserDisconnected;
|
||||
public void InvokeOnUserDisconnected(UDPEndpoint DisconnectedUser){
|
||||
onUserDisconnected?.Invoke(DisconnectedUser, new EventArgs());
|
||||
onUserDisconnected?.Invoke(DisconnectedUser);
|
||||
}
|
||||
|
||||
public event Action onServerDisconnected;
|
||||
public void InvokeOnServerDisconnected(){
|
||||
Alive = false;
|
||||
onServerDisconnected?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Mistox.Client {
|
||||
public class UDPEndpoint {
|
||||
public string UserName { get; set; } = ""; // The Players UserName
|
||||
public bool Alive { get; set; } = true; // Is the connection alive
|
||||
public IPEndPoint Destination { get; set; } // The IP destination for the connection
|
||||
public mUDPClient Connection { get; set; } // The UDP Client Object
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Mistox.Attributes;
|
||||
|
||||
[mPacket(0xFF)]
|
||||
public class UserConnectionPacket {
|
||||
string UserName { get; set; }
|
||||
long RemoteIP { get; set; }
|
||||
int Port { get; set; }
|
||||
}
|
||||
Reference in new issue
Block a user