Null check instead of initilizing empty work
This commit is contained in:
1 parent
c8a0aef289
commit
d7581fbdeb
2 files changed
+10
-22
No files matched your search
@@ -22,9 +22,6 @@ namespace Mistox.Server {
|
||||
public MistoxServer(IPEndPoint ListenerAddress, string serverName) {
|
||||
ServerName = serverName;
|
||||
Listener = new ServerListener(ListenerAddress, this);
|
||||
onUserConnected += (_) => {};
|
||||
onDataReceived += (_, _) => {};
|
||||
onUserDisconnected += (_) => {};
|
||||
Console.WriteLine( "The Server is initilized and waiting for clients to connect at port : " + ListenerAddress.Port );
|
||||
}
|
||||
|
||||
@@ -75,13 +72,13 @@ namespace Mistox.Server {
|
||||
// Events
|
||||
/////////////////////////////
|
||||
|
||||
public event Action<ServerConnection> onUserConnected;
|
||||
public event Action<ServerConnection>? onUserConnected;
|
||||
public void InvokeUserConnected( ServerConnection user ){
|
||||
Connections[user.UserName] = user;
|
||||
onUserConnected?.Invoke( user );
|
||||
}
|
||||
|
||||
public event Action<ServerConnection, object> onDataReceived;
|
||||
public event Action<ServerConnection, object>? onDataReceived;
|
||||
public void InvokeDataReceived( ServerConnection user, dynamic data ){
|
||||
switch (data) {
|
||||
case UserAuthPacket packet when !user.IsAuthenticated:
|
||||
@@ -104,7 +101,7 @@ namespace Mistox.Server {
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<ServerConnection> onUserDisconnected;
|
||||
public event Action<ServerConnection>? onUserDisconnected;
|
||||
public void InvokeUserDisconnected( ServerConnection user ){
|
||||
Connections.Remove(user.UserName, out _);
|
||||
onUserDisconnected?.Invoke( user );
|
||||
|
||||
Reference in new issue
Block a user