Esempio n. 1
0
        //static event Action<string, string> MessageEvent;
        static void Main(string[] args)
        {
            //MessageEvent += MessageHandler;

            //MessageEvent("vasya", "Hello");

            Chat       chat    = new Chat();
            ChatClient client1 = new ChatClient(chat)
            {
                Username = "******"
            };
            ChatClient client2 = new ChatClient(chat)
            {
                Username = "******"
            };
            ChatClient client3 = new ChatClient(chat)
            {
                Username = "******"
            };
            ChatClient client4 = new ChatClient(chat)
            {
                Username = "******"
            };

            chat.AddClient(client1);
            chat.AddClient(client2);
            chat.AddClient(client3);
            chat.AddClient(client4);


            client1.SendMessage("Hello!");
            chat.RemoveClient(client2);
            client3.SendMessage("Hi!");

            Thread.Sleep(2000);
            chat.AddClient(new ChatClient(chat)
            {
                Username = "******"
            });

            Console.Read();
        }