Beispiel #1
0
        /// <summary>
        /// Pushes out messages to the connected clients
        /// </summary>
        /// <param name="type"></param>
        /// <param name="user"></param>
        /// <param name="message"></param>
        public void SendMsgToAll(MessageType type, ServerUserConnection user, string message)
        {
            Console.WriteLine($"{user?.userName}: {message}");

            foreach (var connection in userToConnections)
            {
                Console.WriteLine($"Sending to {connection.Value.userName}");
                Utils.SendInformation(type, connection.Value.stream, message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Connects a user to the server and adds them to the dictionary userToConnections
        /// </summary>
        /// <param name="client"></param>
        public void ReceiveUser(TcpClient client)
        {
            ServerUserConnection connection = new ServerUserConnection(this, client); // Constructor

            userToConnections.Add(connection.userName, connection);
        }