Wire up the event handlers

This commit is contained in:
derek committed 2026-07-03 11:37:41 -07:00
1 parent a04516c470
commit a689f2656f
11 files changed
+90 -76

No files matched your search

+9 -9
View File
@@ -8,13 +8,13 @@ using Mistox.Server;
namespace Mistox {
public class ServerInterface {
public static MistoxServer ServerInstance; // Server Data
public static ServerListener Listener; // Server Listener
public static ConcurrentDictionary<string, TcpClientConnection> Connections; // Server Connections
public static MistoxServer ServerInstance; // Server Data
public static ServerListener Listener; // Server Listener
public static ConcurrentDictionary<string, TcpClientConnection> Connections; // Server Connections
public event EventHandler onUserConnected;
public event EventHandler onReceive;
public event EventHandler onUserDisconnected;
public event Action<TcpClientConnection> onUserConnected; // User connected event handler
public event Action<dynamic> onDataReceived; // Data received event handler
public event Action<TcpClientConnection> onUserDisconnected; // User disconnected event handler
public ServerInterface( int port, string serverName ) {
@@ -28,9 +28,9 @@ namespace Mistox {
Connections = new ConcurrentDictionary<string, TcpClientConnection>();
// Setup the event handlers
ServerInstance.onUserConnected += onUserConnected;
ServerInstance.onReceived += onReceive;
ServerInstance.onUserDisconnected += onUserDisconnected;
ServerInstance.onUserConnected += (TcpClientConnection connectedUser) => { onUserConnected?.Invoke(connectedUser); };
ServerInstance.onDataReceived += (dynamic data) => { onDataReceived?.Invoke(data); };
ServerInstance.onUserDisconnected += (TcpClientConnection disconnectedUser) => { onUserDisconnected?.Invoke(disconnectedUser); };
// Start listening for connections and wire up the server
Listener = new ServerListener();