public void quit(Chatter c)
 {
     try
     {
         sendMessage(new Message(Header.Quit, c.getAlias()));
     }
     catch (IOException e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 2
0
 public void quit(Chatter c)
 {
     try
     {
         sendMessage(new Message(Message.Header.QUIT_CR, c.getAlias()));
         this.close();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
 public void join(Chatter c)
 {
     try
     {
         sendMessage(new Message(Header.Join, c.getAlias()));
         chatter = c;
     }
     catch (IOException e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 4
0
 public void quit(Chatter c)
 {
     if (_users.Contains(c))
     {
         _users.Remove(c);
         Console.WriteLine("(Message from Chatroom : " + _topic + ") " + c.getAlias() + " has left the room.");
     }
     for (int i = 0; i < _users.Count(); i++)
     {
         _users.ElementAt(i).quitNotification(c);
     }
 }
Ejemplo n.º 5
0
 public void join(Chatter c)
 {
     if (!_users.Contains(c))
     {
         _users.Add(c);
         Console.WriteLine("(Message from Chatroom : " + _topic + ") " + c.getAlias() + " has joined the room.");
         for (int i = 0; i < _users.Count(); i++)
         {
             _users.ElementAt(i).joinNotification(c);
         }
     }
 }
Ejemplo n.º 6
0
        public void quit(Chatter c)
        {
            if (!listChatter.Contains(c))
            {
                listChatter.Remove(c);

                Console.WriteLine("(Message from Chatroom : " + topic + ") " + c.getAlias() + " has join the room.");
                for (int i = 0; i < listChatter.Count; i++)
                {
                    listChatter[i].quitNotification(c);
                }
            }
        }
Ejemplo n.º 7
0
        public void joinNotification(Chatter c)
        {
            List <string> data = new List <string>(1);

            data.Add(c.getAlias());
            try
            {
                sendMessage(new Message(Message.Header.JOIN_TOPIC, data)); // todo: proper join
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 8
0
        public void post(String msg, Chatter c)
        {
            Message message = new Message(Message.Header.POST);

            message.addData(c.getAlias());
            message.addData(msg);
            try
            {
                sendMessage(message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 9
0
        public void quitNotification(Chatter c)
        {
            List <string> data = new List <string>(1);

            data.Add(c.getAlias());

            try
            {
                sendMessage(new Message(Message.Header.QUIT_CR, data));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 10
0
        public String receiveAMessage(String _message, Chatter c)
        {
            List <String> data = new List <String>(2);

            data.Add(c.getAlias());
            data.Add(_message);
            try
            {
                sendMessage(new Message(Header.Receive, data));
                Console.WriteLine(_message);
            } catch (IOException e)
            {
                Console.WriteLine(e);
            }
            return(_message);
        }
Ejemplo n.º 11
0
        public void join(Chatter c)
        {
            try
            {
                List <string> temp = new List <string>();
                temp.Add(c.getAlias());
                //temp.Add(c.getPassword());

                sendMessage(new Message(Message.Header.JOIN_CR, temp));
                chatter = c;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 12
0
        public String joinNotification(Chatter c)
        {
            String        _message = "";
            List <String> data     = new List <String>(1);

            data.Add(c.getAlias());
            try
            {
                sendMessage(new Message(Header.Joined, data));
            }
            catch (IOException e)
            {
                Console.WriteLine(e);
            }
            return(_message);
        }
Ejemplo n.º 13
0
        public void receiveAMessage(string msg, Chatter c)
        {
            List <string> data = new List <string>(2);

            data.Add(c.getAlias());
            data.Add(msg);

            try
            {
                sendMessage(new Message(Message.Header.GET, data));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public void post(String msg, Chatter c)
        {
            //System.out.println("nous envoyons un message");
            Message message = new Message(Header.Post);

            message.addString(c.getAlias());
            message.addString(msg);
            try
            {
                //System.out.println("message en cours d'envoie");
                sendMessage(message);
            }
            catch (IOException e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 15
0
        public void join(Chatter c)
        {
            if (!listChatter.Contains(c))
            {
                listChatter.Add(c);
                Console.WriteLine("(Message from Chatroom : " + topic + ") " + c.getAlias() + " has join the room.");
                for (int i = 0; i < listChatter.Count; i++)
                {
                    listChatter[i].joinNotification(c);
                }
            }


            /*
             * System.Console.WriteLine(" Le pseudo : " +c.getAlias() + " vient de joindre le topic : "+this.topic);
             * listChatter.Add(c); */
        }
Ejemplo n.º 16
0
 public void receiveAMessage(string msg, Chatter c)
 {
     Console.WriteLine("(At " + _alias + ") : " + c.getAlias() + " $> " + msg);
 }
Ejemplo n.º 17
0
 public String quitNotification(Chatter c)
 {
     return(c.getAlias() + " Disconnected");
 }
Ejemplo n.º 18
0
 public String joinNotification(Chatter c)
 {
     return(c.getAlias() + " Joined");
 }
Ejemplo n.º 19
0
 public String receiveAMessage(string msg, Chatter c)
 {
     return(c.getAlias() + " : " + msg);
 }
Ejemplo n.º 20
0
 public void post(String msg, Chatter c)
 {
     if (_users.Contains(c))
     {
         for (int i = 0; i < _users.Count(); i++)
         {
             _users.ElementAt(i).receiveAMessage(msg, c);
         }
     }
     else
     {
         Console.WriteLine("ERROR : message \"" + msg + "\" could not be sent. Sender " + c.getAlias() + " is not in the chatroom");
     }
 }
Ejemplo n.º 21
0
        public void post(string msg, Chatter c)
        {
            if (listChatter.Contains(c))
            {
                for (int i = 0; i < listChatter.Count; i++)
                {
                    listChatter[i].receiveAMessage(msg, c);
                }
            }
            else
            {
                Console.WriteLine("ERROR : message \"" + msg + "\" could not be sent. Sender " + c.getAlias() + " not in the chatroom");
            }

            //System.Console.WriteLine(c.getAlias() + " : " + msg);
        }
Ejemplo n.º 22
0
 public void join(Chatter c) // Add a chatter to a chatroom
 {
     try
     {
         this.listChatters.Add(c);
         Console.WriteLine("(Message from Chatroom: " + this.getTopic() + " ) " + c.getAlias() + " has join the room.");
     }
     catch (NullReferenceException)
     {
         Console.WriteLine("Chatter NULL");
     }
 }