Exemplo n.º 1
0
        public void onReveivedMessage(string msg, string src, string dest)
        {
            //Update main conversation
            if (dest == null || dest.Length <= 0)
            {
                eventReceiptedMessage?.Invoke(msg, src);
                return;
            }

            //Update private room
            foreach (PrivateChatRoom cr in chatRooms)
            {
                if (cr.Participant == src)
                {
                    cr.receiveMessage(msg);
                    cr.display();
                    return;
                }
            }

            //Create new private room
            Thread th = new Thread(() =>
            {
                PrivateChatRoom chatRoom = new PrivateChatRoom(src);
                chatRooms.Add(chatRoom);
                eventUpdateChatRooms?.Invoke();

                chatRoom.display();
                chatRoom.receiveMessage(msg);

                System.Windows.Threading.Dispatcher.Run();//Call in the main thread
            });

            th.SetApartmentState(ApartmentState.STA);
            th.IsBackground = true;
            th.Start();
        }
Exemplo n.º 2
0
        public void openPrivateRoom(string dest)
        {
            if (dest == null || dest.Length <= 0)
            {
                return;
            }

            foreach (PrivateChatRoom cr in chatRooms)
            {
                if (cr.Participant == dest)
                {
                    cr.display();
                    return;
                }
            }

            //create new chatroom
            PrivateChatRoom chatRoom = new PrivateChatRoom(dest);

            chatRooms.Add(chatRoom);
            eventUpdateChatRooms?.Invoke();

            chatRoom.display();
        }
Exemplo n.º 3
0
 public ChatRoomView(PrivateChatRoom chatRoom)
 {
     InitializeComponent();
     this.chatRoom = chatRoom;
     this.Title    = "ChatRoom-" + controller.nickname + ": " + chatRoom.Participant;
 }