Пример #1
0
        public void OnReceivedMessage(ChatLib.MessageChat message)
        {
            // Suivant le type de message
            switch (message.MessageType)
            {
                case ChatLib.MessageType.None: break;

                case ChatLib.MessageType.ClientPrivateMessage:
                    if (message.SenderName == PrivateChatName)
                    {
                        this.writeUsername(message.SenderName);
                        this.writeMessage(message.ContentMessage);
                    }
                    break;
                case ChatLib.MessageType.ClientPrivateImage:
                    try
                    {

                        if (message.SenderName == PrivateChatName)
                        {

                            this.writeUsername(message.SenderName);
                            this.drawImage(message.ContentMessage);
                        }
                    }
                    catch (JsonReaderException)
                    {
                        MessageBox.Show("La taille de l'image excède 100ko");
                    }
                    break;
            }
        }
Пример #2
0
        public void OnReceivedMessage(ChatLib.MessageChat message)
        {
            // Suivant le type de message
            switch (message.MessageType)
            {
                case ChatLib.MessageType.None: break;

                // Message texte chat room
                case ChatLib.MessageType.ClientChatRoomMessage:
                    if (message.TargetName == chatRoomName)
                    {
                        this.writeUsername(message.SenderName);
                        this.writeMessage(message.ContentMessage);
                    }
                    break;

                case ChatLib.MessageType.UpdateConnectedUsersInChatRoom:
                    if (message.TargetName == chatRoomName)
                    {
                        this.listClient.Items.Clear();
                        string[] listClient = message.ContentMessage.Split('\\');
                        foreach (string s in listClient)
                        {
                            ListViewItem item = new ListViewItem(s);
                            this.listClient.Items.Add(item);
                        }

                    }
                    break;

                case ChatLib.MessageType.ClientPrivateMessage:
                    break;

                case ChatLib.MessageType.ClientChatRoomImage:

                    if (message.TargetName == chatRoomName)
                    {
                        this.writeUsername(message.SenderName);
                        this.drawImage(message.ContentMessage);
                    }
                    break;

            }
        }
Пример #3
0
        public void UpdateConnectedUsersInChatRoom(ChatLib.MessageChat message)
        {
            if (message.TargetName == chatRoomName)
            {
                string[] listClient = message.ContentMessage.Split('\\');
                this.listClient.Items.Clear();
                foreach (string s in listClient)
                {
                    //if (s.Length > 0 && client.UserName != s)
                    //{
                    //    if (this.listClient.FindItemWithText(s) == null)
                    //    {
                    //        ListViewItem item = new ListViewItem(s);
                    //        this.listClient.Items.Add(item);
                    //    }
                    //}
                    if (s.Length > 0 && client.UserName != s)
                    {
                        ListViewItem item = new ListViewItem(s);
                        this.listClient.Items.Add(item);
                    }

                }
            }
        }