Exemple #1
0
        public void on_btChat_clicked(object sender, EventArgs a)
        {
            TreeModel tm;
            TreeIter ti;
             		string nickname ="";

            if (treeviewContacts.Selection.GetSelected(out tm, out ti))
                {
                        nickname = (string) tm.GetValue (ti, 0);
                        LLChatWindow chat = new LLChatWindow(myLife,myLife.FindIpAddress(nickname));
                        this.chats.Add(chat.RemoteIP, chat);
                }

            //TODO: Add your code here.
        }
Exemple #2
0
        public void on_chat1_activate(object sender, EventArgs a)
        {
            System.Console.Write("\ntype the remote ip: ");

            LLChatWindow chat = new LLChatWindow(myLife, System.Console.ReadLine());
            this.chats.Add(chat.RemoteIP, chat);
        }
Exemple #3
0
        public void Listen()
        {
            TcpListener listener;
               try
               {
            listener = new TcpListener(port);
            listener.Start();

            while(true)
            {
             Socket connection = listener.AcceptSocket();

             string ipSender = (((IPEndPoint)connection.RemoteEndPoint).Address.ToString ());

             string nickname = this.myLife.FindNickname(ipSender);

            /*     if (nickname != @"/notInList")
             {
              System.Console.WriteLine(nickname + " Says: \n");
             }
             else
             {
              //System.Console.WriteLine("Warning. You have received a message from a member that is not in your contact list.\n Member Name: " +life.Name + "\n");
             }
            */
             NetworkStream socketstream = new NetworkStream( connection );

             BinaryReader reader = new BinaryReader( socketstream );
             string message = reader.ReadString();

             if(this.chats.Contains(ipSender))
             {
              //LLChatWindow chat = new LLChatWindow(ipSender);
              ((LLChatWindow) this.chats[ipSender]).showmessage(nickname + ": " + message);
             }
             else
             {
              LLChatWindow chat = new LLChatWindow(myLife,ipSender);
              chats.Add(chat.RemoteIP, chat);
              ((LLChatWindow) this.chats[ipSender]).showmessage(message);
             }
            }
               }
               catch(Exception ex)
               {
            throw(ex);
               }
        }