private static void OnClientConnected(ClientConnectedArgs firstTimeConnection) { //update DB TCPServerDB.UpdateUserConnectionStatus(firstTimeConnection.UserName, true); EventHandler <ClientConnectedArgs> handler = ClientConnected; if (handler != null) { handler(null, firstTimeConnection); } }
private static void OnClientDisconnected(ClientDisconnectedArgs e) { //update DB TCPServerDB.UpdateUserConnectionStatus(e.UserName, false); ClientHandler ch; //trying to remove the disconnected user SocketConnections.TryGetValue(e.Id, out ch); if (ch != null) { ch.TokenSourceConnection.Cancel(); ch.Dispose(); SocketConnections.Remove(e.Id); } EventHandler <ClientDisconnectedArgs> handler = ClientDisconnected; if (handler != null) { handler(null, e); } }