Exemplo n.º 1
0
        public void PrintConnectedClients(Client client)
        {
            string[] connectedClients = stringMethods.ListOfConnectedClientsToString(client).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            Console.WriteLine("Connected clients:");

            foreach (var connectedClient in connectedClients)
            {
                Console.WriteLine(connectedClient.Trim());
            }

            Console.WriteLine($"Total: {client.ConnectedClients.Count} clients.");
            Console.WriteLine();
        }
Exemplo n.º 2
0
        private void SendListOfConnectedClients(IPEndPoint iPEndPoint)
        {
            string message = null;

            if (ConnectedClients.Count == 0)
            {
                message = "@#" + name;
            }
            else
            {
                message = "@#" + name + ", " + stringMethods.ListOfConnectedClientsToString(this);
            }

            byte[] data = Encoding.Unicode.GetBytes(message);
            socket.SendTo(data, iPEndPoint);
        }