Esempio n. 1
0
        public void Run()
        {
            try
            {
                Message message;
                while ((message = GetMessage()) != null)
                {
                    switch (message.head)
                    {
                    case (Message.Header)Header.JOINED:
                        pseudos.Add(message.data[0]);
                        if (user != null)
                        {
                            user.JoinNotification(new TextChatter(message.data[0]));
                        }
                        Console.WriteLine(pseudos);
                        break;

                    case (Message.Header)Header.GET:
                        messages.Add(message);
                        if (user != null)
                        {
                            user.ReceiveAMessage(message.data[1], new TextChatter(message.data[0]));
                        }
                        Console.WriteLine("get message" + messages);
                        break;

                    case (Message.Header)Header.LEFT:
                        pseudos.Remove(message.data[0]);
                        if (user != null)
                        {
                            user.QuitNotification(new TextChatter(message.data[0]));
                        }
                        Console.WriteLine(pseudos);
                        break;
                    }
                }
                Console.WriteLine("End of while");
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
            }
            catch (NotSupportedException e)
            {
                Console.WriteLine(e.ToString());
            }
        }