Example #1
0
        static void Main()
        {
            IChatMediator chatMediator = new ChatMediator();

            User user1 = new ChatUser(chatMediator)
            {
                Name     = "Sinan",
                UserName = "******"
            };

            User user2 = new ChatUser(chatMediator)
            {
                Name     = "Behzat",
                UserName = "******"
            };


            User bot1 = new ChatBot(chatMediator)
            {
                Name     = "Bot",
                UserName = "******"
            };

            chatMediator.AddUser(user1);
            chatMediator.AddUser(user2);
            chatMediator.AddUser(bot1);

            user1.SendMessage("Selam?", user2.UserName);
            user2.SendMessage("İyiyim sen?", user1.UserName);
            bot1.SendMessage("konuşmalara dikkat edelim.", user1.UserName);
            user1.SendMessage("eyvallah.", bot1.UserName);

            Console.Read();
        }
Example #2
0
        /// <summary>
        /// Mediators this instance.
        /// </summary>
        public void Mediator()
        {
            ////creating the object of ChatMediator class
            IChatMediator chatMediator = new ChatMediator();
            ////create users and add them to chat mediator's user list
            IUser paramesh = new BasicUser(chatMediator, "paramesh");
            IUser manju    = new PremiumUser(chatMediator, "manju");
            IUser karan    = new PremiumUser(chatMediator, "karan");

            chatMediator.AddUser(paramesh);
            chatMediator.AddUser(manju);
            chatMediator.AddUser(karan);
            //// send message
            karan.SendMessage("Hello Everyone!");
            Console.WriteLine("===============================================");
            paramesh.SendMessage("hiii");
            Console.ReadLine();
        }