Exemplo n.º 1
0
        public override void Send(string from, string to, string message)
        {
            Participant participant = _participants[to];

            if (participant != null)
            {
                participant.Receive(from, message);
            }
        }
Exemplo n.º 2
0
        public override void SendMany(string from, List <Participant> to, string message)
        {
            foreach (Participant entry in to)
            {
                //to replace the [to] argument with participants[entry.Name]
                Participant participant = participants[entry.Name];
                if (participant != null && participants[from] != participants[entry.Name])
                {
                    participant.Receive(from, message);
                }

                else
                {
                    Console.WriteLine("{0} you can't send yourself a message!", from);
                }
            }
        }
Exemplo n.º 3
0
        public override void SendAll(string from, string message)

        {
            //loop the chatroom and send the same messgae to all registered users
            foreach (KeyValuePair <string, Participant> entry in participants)
            {
                //to replace the [to] argument with participants[entry.Key]
                Participant participant = participants[entry.Key];

                if (participant != null && participants[from] != participants[entry.Key])
                {
                    participant.Receive(from, message);
                }

                else
                {
                    Console.WriteLine("{0} you can't send yourself a message!", from);
                }
            }
        }