private static void OnConnect(IAsyncResult ar)
        {
            var tcpClient = listener.EndAcceptTcpClient(ar);

            Console.WriteLine($"Client connected from {tcpClient.Client.RemoteEndPoint}");

            Clientmanager man = new Clientmanager(tcpClient);


            foreach (Clientmanager c in clients)
            {
                man.Write($"{c.UserName} is connected");
                Console.WriteLine($"{c.UserName} is connected");
            }
            clients.Add(man);

            Thread notifyClients = new Thread(() =>
            {
                NotifyClients(clients, $"Client connected from {tcpClient.Client.RemoteEndPoint}\r\n");
            });

            notifyClients.Start();


            listener.BeginAcceptTcpClient(new AsyncCallback(OnConnect), null);
        }
 public static void SendMessage(Clientmanager manager, string message)
 {
     foreach (Clientmanager client in clients)
     {
         if (manager != client)
         {
             client.Write(message);
         }
     }
 }
 internal static void Disconnect(Clientmanager clientManager)
 {
     clients.Remove(clientManager);
     Console.WriteLine("Client disconnected");
     NotifyClients(clients, "Client disconnected");
 }