Ejemplo n.º 1
0
        public void LogChatMessage(RTChatMessage message)
        {
            ChatTime += (uint)(int)(DateTime.UtcNow - LastSeen).TotalSeconds;
            LastSeen  = DateTime.UtcNow;
            ChatMessages.Add(message);
            TotalChatMessages += 1;

            UserId      = message.UserIdStr;
            DisplayName = message.DisplayName;
            Badges      = message.Badges;
            UserName    = message.UserName;
            UserType    = message.UserType;
            IsTurbo     = message.IsTurbo;
            if (message.Message.ToLowerInvariant().Contains(message.TwitchBotName.ToLowerInvariant()))
            {
                IsHighlightedUser = true;
            }
            IsChanged = true;
            var sentimentresults = analyzer.PolarityScores(message.Message);

            PositiveSentiment += sentimentresults.Positive;
            NegativeSentiment += sentimentresults.Negative;
            NeutralSentiment  += sentimentresults.Neutral;
            CompoundScore     += sentimentresults.Compound;
        }
Ejemplo n.º 2
0
        public ChatViewModel()
        {
            Activator = new ViewModelActivator();
            var hasChatMessage = this.WhenAnyValue(vm => vm.ChatMessage)
                                 .Select(msg => !string.IsNullOrEmpty(msg));

            ExecuteSendMessage = ReactiveCommand.CreateFromTask(SendMessage, hasChatMessage);

            _connection = new HubConnectionBuilder()
                          // Local
                          .WithUrl("https://localhost:5001/ChatHub")
                          // WebService
                          //.WithUrl("https://stayconnectedwithsignalrwebapp.azurewebsites.net/ChatHub")
                          // AF
                          // .WithUrl("https://stayconnectedwithsignalrazurefunction.azurewebsites.net/api/")
                          .WithAutomaticReconnect()
                          .Build();

            this.WhenActivated(async(CompositeDisposable disposable) =>
            {
                await _connection.StartAsync();

                _connection.On <string>("NewMessage", (jsonChatMessage) =>
                {
                    var chatMessage = JsonConvert.DeserializeObject <ChatMessage>(jsonChatMessage);
                    ChatMessages.Add(chatMessage);
                });
            });
        }
        private void AddTextSend(ChatLogEventArgs args)
        {
            var message = new ChatMessage {
                PrevSide = _curside
            };

            if (ChatSettings.IsCustomServerConsoleNameEnabled)
            {
                message.SenderName = string.IsNullOrWhiteSpace(ChatSettings.CustomServerConsoleName) ? "Server Admin" : ChatSettings.CustomServerConsoleName;
            }
            else
            {
                message.SenderName = "Server Admin";
            }
            message.Text = args.Message;
            message.Side = MessageSide.Me;
            if (ChatSettings.IsTimestampingEnabled)
            {
                message.Timestamp = args.Timestamp;
            }
            ChatMessages.Add(message);
            _curside = MessageSide.Me;
            if (ChatSettings.IsAutoScrollEnabled)
            {
                View.ScrollConversationToEnd();
            }
        }
Ejemplo n.º 4
0
        private void informGUI(string obj, Socket socket)
        {
            App.Current.Dispatcher.Invoke(() =>
            {
                string[] unformatted = obj.Split(' ');

                var messages = new ObservableCollection <MessageVM>();
                var name     = unformatted[0];
                string msg   = name + ": ";

                while (!msg.Contains("\r\n"))
                {
                    for (int i = 1; i < unformatted.Length; i++)
                    {
                        msg += unformatted[i] + " ";
                    }
                }

                messages.Add(new MessageVM(msg, DateTime.Now));
                ChatMessages.Add(msg);

                if (!ChatMessages.Contains(name))
                {
                    User.Add(new UserVM(name, messages));
                }



                //}
            });
        }
Ejemplo n.º 5
0
        private void OnWoWChatMessage(object sender, WoWEventHandler.ChatMessageArgs args)
        {
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
            {
                try
                {
                    ChatMessages.Add(args);
                    if (args.ChatChannel == "Say" && BeepSay)
                    {
                        PlayBeep();
                    }
                    if (args.ChatChannel == "Yell" && BeepYell)
                    {
                        PlayBeep();
                    }
                    if (args.Message.ToLower().Contains(Stats.ToonName) && BeepName)
                    {
                        PlayBeep();
                    }

                    if (!LogChat)
                    {
                        return;
                    }
                    args.ToString().Log(LogFiles.ChatLog);
                }
                catch
                {
                }
            }));
        }
Ejemplo n.º 6
0
        private async Task SendChatMessage(ChatMessage msg)
        {
            try
            {
                IsScrollingTop = false;
                var token = App.User.api_token;
                ChatMessages.Add(msg);
                Message = string.Empty;
                await RaisePropertyChanged(nameof(Message));
                await RaisePropertyChanged(nameof(ChatMessages));
                await RaisePropertyChanged(nameof(RequestScroll));

                var filePaths = msg.Files.Select(x => x.FilePath);
                ////Send to server and handle failure
                var chat = await _networkService.SendChatFileAsync(token, msg.SurID, msg.Type, msg.Content, filePaths, 0, App.User.ID);

                if (chat != null)
                {
                    msg.ChatID    = chat.lastID;
                    msg.FileIndex = chat.fileIndex;
                }
                else
                {
                    msg.SendStatus = 2;
                }

                //Log.Info(Constants.AppConfig.LogTag, "Sent:" + msg.ChatID);
            }
            catch (Exception ex)
            {
                //Log.Error(Constants.AppConfig.LogTag, ex.ToString());
                //Log.Error(Constants.AppConfig.LogTag, ex.StackTrace);
            }
        }
Ejemplo n.º 7
0
 public ChatMessageEntity AddChatMessage(ChatMessageEntity message)
 {
     lock (ChatMessages)
     {
         ChatMessages.Add(message);
         return(ChatMessages.Last());
     }
 }
Ejemplo n.º 8
0
 private void ServerConnection_MessageWasRecieved(object sender, CustomEventArgs e)
 {
     RecievedMessage = e.ChatMessage;
     App.Current.Dispatcher.Invoke((System.Action) delegate
     {
         ChatMessages.Add(RecievedMessage);
     });
 }
Ejemplo n.º 9
0
        private void OnChatPlayerMessage(ChatPlayerMessage chatPlayerMessage)
        {
            if (StoreChatMessages)
            {
                ChatMessages.Add(chatPlayerMessage);
            }

            ChatPlayerMessage?.Invoke(chatPlayerMessage);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///		Handler for ChatMessage related messages.
        /// </summary>
        /// <param name="chatMessage"> Message to handle. </param>
        /// <param name="notification"> Type of operation. </param>
        private void HandleChatMessageNotification(ChatMessage chatMessage, string notification)
        {
            // todo: set listeners to be specific to chat room
            if (chatMessage.ChatRoomId != Id)
            {
                return;
            }

            switch (notification)
            {
            case "Add":
            {
                // todo: add this to dto model
                // set user for message
                chatMessage.User = Users.SingleOrDefault(i => i.Id == chatMessage.UserId);

                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        if (ChatMessages.All(i => i.Id != chatMessage.Id))
                        {
                            ChatMessages.Add(chatMessage);
                        }
                    });
                break;
            }

            case "Remove":
            {
                var messageToRemove = ChatMessages.SingleOrDefault(i => i.Id == chatMessage.Id);

                if (messageToRemove != null)
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() => { ChatMessages.Remove(messageToRemove); });
                }

                break;
            }

            case "SubmitEdit":
                _chatMessageDataService.Edit(chatMessage);
                break;

            case "Edit":
            {
                var messageToEdit = ChatMessages.SingleOrDefault(i => i.Id == chatMessage.Id);

                if (messageToEdit != null)
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() => messageToEdit.Message = chatMessage.Message);
                }

                break;
            }
            }
        }
Ejemplo n.º 11
0
        private async Task LoadChatMessages(DateTime datetime, bool isNewChatQuery)
        {
            if (isNewChatQuery)
            {
                EndTime = DateTime.Now;
            }
            else
            {
                IsScrollingTop = true;
            }

            List <ChatMessage> listChat = await _networkService.QueryChatAsync(App.User.api_token, EventId, Constants.ChatType.InternalChat, isNewChatQuery, datetime);

            var hasNewChat = false;

            if (listChat != null && listChat.Count > 0)
            {
                if (isNewChatQuery)
                {
                    listChat.Reverse();
                }
                foreach (var chat in listChat)
                {
                    chat.IsFromMe = chat.UserID == App.User.ID;
                    if (chat.CreateTime != DateTime.MinValue && BeginTime > chat.CreateTime)
                    {
                        BeginTime = chat.CreateTime.Value;
                    }
                    if (isNewChatQuery)
                    {
                        var existed = ChatMessages.Any(c => c.ChatID == chat.ChatID);
                        if (!existed)
                        {
                            hasNewChat = true;
                            ChatMessages.Add(chat);
                        }
                    }
                    else
                    {
                        hasNewChat = true;
                        ChatMessages.Insert(0, chat);
                    }
                }
            }

            if (hasNewChat)
            {
                await RaisePropertyChanged(nameof(ChatMessages));
            }
            if (hasNewChat && isNewChatQuery && !IsScrollingTop)
            {
                await RaisePropertyChanged(nameof(RequestScroll));
            }
        }
Ejemplo n.º 12
0
        public void SubmitChatMessage()
        {
            if (string.IsNullOrEmpty(ChatMessage))
            {
                return;
            }

            ChatMessages.Add(new ChatMessage {
                Message = ChatMessage
            });
            ChatMessage = string.Empty;
        }
Ejemplo n.º 13
0
        public bool TryParseMessage(WowChat type, long timestamp, List <string> args)
        {
            if (args.Count < 6)
            {
                return(false);
            }

            WowChatMessage chatMessage = new(type, timestamp, args);

            ChatMessages.Add(chatMessage);

            if (Config.ChatProtocols)
            {
                try
                {
                    string typeName = chatMessage.Type switch
                    {
                        WowChat.ADDON => "misc",
                        WowChat.CHANNEL => "channel",
                        WowChat.DND => "misc",
                        WowChat.FILTERED => "filtered",
                        WowChat.GUILD => "guild",
                        WowChat.GUILD_ACHIEVEMENT => "guild",
                        WowChat.IGNORED => "misc",
                        WowChat.MONSTER_EMOTE => "npc",
                        WowChat.MONSTER_PARTY => "npc",
                        WowChat.MONSTER_SAY => "npc",
                        WowChat.MONSTER_WHISPER => "npc",
                        WowChat.MONSTER_YELL => "npc",
                        WowChat.RAID_BOSS_EMOTE => "npc",
                        WowChat.RAID_BOSS_WHISPER => "npc",
                        WowChat.SYSTEM => "system",
                        _ => "normal",
                    };

                    string protocolName = ProtocolName(typeName);
                    string dirName      = Path.GetDirectoryName(protocolName);

                    if (!Directory.Exists(dirName))
                    {
                        Directory.CreateDirectory(dirName);
                    }

                    File.AppendAllText(protocolName, $"{chatMessage}\n");
                }
                catch { }
            }

            OnNewChatMessage?.Invoke(chatMessage);

            return(true);
        }
Ejemplo n.º 14
0
        public void world_chat_message(string txt, string html)
        {
            //log.Debug(txt);
            try
            {
                ChatType ct = ChatType.Other;

                if (txt.Contains("[World]"))
                {
                    ct = ChatType.World;
                }
                else if (txt.Contains("[Alliance]"))
                {
                    ct = ChatType.Alliance;
                }
                else if (txt.Contains("[Officer]"))
                {
                    ct = ChatType.Officers;
                }
                else if (txt.Contains("whisper"))
                {
                    ct = ChatType.Whisper;
                }

                var cm = new JS.ChatMessage {
                    ChatType = ct, Message = txt
                };
                AnalyzeMsg(html, cm);

                //muszę tak bo jestem w innym wątku... i może boleć

                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        ChatMessages.Add(cm);
                    }
                    catch (Exception e)
                    {
                        log.Error(e.Message, e);
                    }
                }), DispatcherPriority.Normal);

                DoChatMessage(cm);
            }
            catch (Exception e)
            {
                log.Error(e.Message, e);
                log.Error("Message: " + html);
            }
        }
        private void AddTextRecieved(ChatLogEventArgs args)
        {
            var message = new ChatMessage
            {
                PrevSide   = _curside,
                SenderName = args.Sender,
                Text       = args.Message,
                Side       = MessageSide.You
            };

            if (ChatSettings.IsTimestampingEnabled)
            {
                message.Timestamp = args.Timestamp;
            }

            ChatMessages.Add(message);
            _curside = MessageSide.You;
            if (ChatSettings.IsAutoScrollEnabled)
            {
                View.ScrollConversationToEnd();
            }

            try
            {
                if (!ChatSettings.IsNotificationsEnabled || ChatSettings.NotificationString == null)
                {
                    return;
                }

                if (ChatSettings.NotificationWords.Any(s => message.Text.Contains(s)))
                {
                    ShowCustomBalloon($"{message.SenderName}: {message.Text}");
                }

                if (ChatSettings.IsFlashWindowNotificationEnabled)
                {
                    Application.Current.MainWindow.FlashWindow();
                }

                if (!ChatSettings.IsNotificationSoundFileEnabled || ChatSettings.NotificationSoundFile == null)
                {
                    return;
                }
                SoundManager.PlayFile(ChatSettings.NotificationSoundFile);
            }
            catch (Exception ex)
            {
                App.LogErrorMessage(ex);
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// TODO: Only for debugging.
 /// </summary>
 public ChatViewModel()
 {
     ChatMessages.Add(new MessageModel()
     {
         Content = "Hello",
         Who     = C.ME,
         Type    = C.MSG_TYPE_TEXT
     });
     ChatMessages.Add(new MessageModel()
     {
         Content = "Thank you!",
         Who     = C.GIY,
         Type    = C.MSG_TYPE_TEXT
     });
 }
Ejemplo n.º 17
0
        private void GetDataFromFirebase()
        {
            Action <Dictionary <string, ChatMessage> > onValueEvent = (Dictionary <string, ChatMessage> messages) =>
            {
                try
                {
                    System.Diagnostics.Debug.WriteLine("---> EVENT GetDataFromFirebase ");

                    Action onSetValueSuccess = () =>
                    {
                    };

                    Action <string> onSetValueError = (string errorDesc) =>
                    {
                    };

                    if (messages == null)
                    {
                    }
                    else
                    {
                        if (messages.Count != 0 && ChatMessages.Count != messages.Count)
                        {
                            foreach (var message in messages.OrderBy(m => m.Value.DateMessageTimeSpan))
                            {
                                message.Value.IsYourMessage = UserCurent.Name == message.Value.UserName;

                                if (ChatMessages.All(m => m.Id != message.Value.Id))
                                {
                                    ChatMessages.Add(message.Value);
                                    System.Diagnostics.Debug.WriteLine("---> add new -> " + message.Value.Id);
                                }
                            }

                            MessagingCenter.Send <ChatVM>(this, "ScrollToEnd");
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("---> error GetDataFromFirebase " + ex.Message);
                    throw;
                }
            };

            _firebaseDatabase.AddValueEvent("chats", onValueEvent);
        }
Ejemplo n.º 18
0
        public async Task SendChatMessage()
        {
            if (string.IsNullOrWhiteSpace(InputText))
            {
                return;
            }

            var chatMessage = new ChatMessage(string.Empty, InputText);

            InputText = string.Empty;
            await PipeStreamWriter.WriteLineAsync(JsonSerializer.Serialize(chatMessage));

            await PipeStreamWriter.FlushAsync();

            chatMessage.SenderName = "You";
            ChatMessages.Add(chatMessage);
        }
        public void HandleNewChatMessageEvent(NewChatMessageEventPayload eventPayload)
        {
            if (eventPayload == null)
            {
                throw new ArgumentNullException("eventPayload");
            }

            if (eventPayload.NewChatMessage.RequestForQuoteId == SelectedRequestForQuote.Identifier)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("Received new chat message: " + eventPayload);
                }

                ChatMessages.Add(eventPayload.NewChatMessage);
            }
        }
Ejemplo n.º 20
0
        private async Task SendText()
        {
            try
            {
                IsScrollingTop = false;
                if (string.IsNullOrWhiteSpace(Message))
                {
                    return;
                }
                var token = App.User.api_token;
                var msg   = new ChatMessage()
                {
                    Content    = Message,
                    IsFromMe   = true,
                    CreateTime = DateTime.Now,
                    SurID      = EventId,
                    Type       = Constants.ChatType.InternalChat,
                    SendStatus = 0
                };
                ChatMessages.Add(msg);
                Message = string.Empty;
                await RaisePropertyChanged(nameof(Message));
                await RaisePropertyChanged(nameof(ChatMessages));
                await RaisePropertyChanged(nameof(RequestScroll));

                var chat = await _networkService.SendChatAsync(token, msg.SurID, msg.Type, msg.Content, 0, App.User.ID);

                if (chat != null)
                {
                    msg.ChatID = chat.lastID;
                }
                else
                {
                    msg.SendStatus = 2;
                }
                await RaisePropertyChanged(nameof(ChatMessages));

                //Log.Info(Constants.AppConfig.LogTag, "Sent: " + msg.Content);
            }
            catch (Exception ex)
            {
                //Log.Error(Constants.AppConfig.LogTag, ex.ToString());
                //Log.Error(Constants.AppConfig.LogTag, ex.StackTrace);
            }
        }
Ejemplo n.º 21
0
        private void FakeData()
        {
            ChatMessages.Add(new ChatMessage()
            {
                IsYourMessage = true,
                //Text = "some mesage  asdasdasd asdklj lj jiopjop jopj opjo pj ioph ioh uiohuio hioio",
                UserName  = "******",
                AttachImg = "alice"
            });

            for (int i = 0; i < 5; i++)
            {
                ChatMessages.Add(new ChatMessage()
                {
                    IsYourMessage = (i % 2 == 0),
                    Text          = "some mesage " + i,
                    UserName      = (i % 2 == 0) ? "Admin" : "some friend"
                });
            }
        }
Ejemplo n.º 22
0
        private void SendMessage(string attach = "")
        {
            var message = new ChatMessage()
            {
                IsYourMessage = true,
                Text          = NewMessageText,
                AttachImg     = attach,
                UserName      = UserCurent.Name,
                UrlPhoto      = UserCurent.UrlPhoto
            };

            ChatMessages.Add(message);

            MessagingCenter.Send <ChatVM>(this, "ScrollToEnd");
            _chatService.SendMessage(message);

            _firebaseDatabase.SetValue(nodePath + "/" + message.Id, message);

            NewMessageText = "";
        }
Ejemplo n.º 23
0
        private void ProcessReceivedMessages()
        {
            if (Enabled)
            {
                while (NewChatMessages.TryDequeue(out var chatMsg))
                {
                    NewMessageReceived = true;

                    if (!ChatWindow.Singleton.Display)
                    {
                        LunaScreenMsg.PostScreenMessage($"{chatMsg.Item1}: {chatMsg.Item2}", 5f, ScreenMessageStyle.UPPER_LEFT);
                    }
                    else
                    {
                        ChatWindow.Singleton.ScrollToBottom();
                    }

                    ChatMessages.Add(chatMsg);
                }
            }
        }
Ejemplo n.º 24
0
        public static void SendMessage(ChatMessage chatMessage)
        {
            ChatMessages.Add(chatMessage);
            chatMessage.ID = ChatMessages.IndexOf(chatMessage);

            ChatUsers.ForEach(user =>
            {
                if (user.UserName != chatMessage.UserName)
                {
                    try
                    {
                        user.SendMessage(chatMessage);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            });
            Console.WriteLine(chatMessage.DateTime + " | " + chatMessage.UserName + " > " + chatMessage.Message);
        }
Ejemplo n.º 25
0
        public void AddMessage(Message message, string receiverUsername)
        {
            string senderUsername = message.SenderUsername;

            bool found = false;

            foreach (Chat chat in UserChats)
            {
                if (ValidChat(chat, senderUsername, receiverUsername))
                {
                    chat.Messages.Add(message);
                    found = true;
                }
            }

            if (!found)
            {
                Chat newChat = new Chat(receiverUsername, senderUsername, new List <Message>());

                newChat.Messages.Add(message);

                lock (UserChatsLock)
                {
                    UserChats.Add(newChat);
                }
            }

            if (_SelectedChat != null)
            {
                if (_SelectedChat.RecipientUsername == receiverUsername || CUsername == receiverUsername)
                {
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        ChatMessages.Add(senderUsername + ": " + message.Content);
                    });

                    OnPropertyChanged("SelectedChat");
                }
            }
        }
Ejemplo n.º 26
0
        public void SendMessage(string msg)
        {
            if (!msg.StartsWith("/"))
            {
                bnetConnection.SendMessage(msg);

                var chatMsg = new BnetEvent();
                chatMsg.EventId   = 0x18;
                chatMsg.Message   = msg;
                chatMsg.Username  = bnetAccount.Username;
                chatMsg.TimeStamp = DateTime.Now;
                ChatMessages.Add(chatMsg);

                Messenger.Default.Send <ScrollDownMessage>(new ScrollDownMessage()
                {
                    Source = this
                });
            }
            else
            {
                if (msg.ToLower() == "/reconnect")
                {
                    ChannelUsers.Clear();
                    ChannelList.Clear();
                    FriendsList.Clear();

                    ChattingStatus = "disconnected";
                    Connect();
                }
                else if (msg.ToLower() == "/version")
                {
                    bnetConnection.SendMessage("/me is using Superiority.NET Beta5 (www.BNET.cc).");
                }
                else
                {
                    bnetConnection.SendMessage(msg);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// First Loading Data
        /// </summary>
        /// <returns></returns>
        private async Task LoadChatMessages()
        {
            EndTime = DateTime.Now;
            List <ChatMessage> listChat = await _networkService.QueryChatAsync(App.User.api_token, EventId, Constants.ChatType.InternalChat);

            if (listChat != null && listChat.Count > 0)
            {
                listChat.Reverse();
                foreach (var chat in listChat)
                {
                    chat.IsFromMe = chat.UserID == App.User.ID;
                    if (chat.CreateTime != DateTime.MinValue && BeginTime > chat.CreateTime)
                    {
                        BeginTime = chat.CreateTime.Value;
                    }
                    ChatMessages.Add(chat);
                }
            }

            await RaisePropertyChanged(nameof(ChatMessages));
            await RaisePropertyChanged(nameof(RequestScroll));
        }
Ejemplo n.º 28
0
        /// <summary>
        ///		Sends the user's message to the server.
        /// </summary>
        private void SendMessage()
        {
            // create chat entry
            var message = new ChatMessage()
            {
                User       = UserInstance.Current,
                Message    = UserText,
                ChatRoomId = Id
            };

            // submit chat to server
            var addedMessage = _chatMessageDataService.Add(message);

            // get id from returned message
            message.Id = addedMessage.Id;

            // add returned message from server which contains id
            ChatMessages.Add(message);

            // clear user text
            UserText = string.Empty;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Send a Message to the current Chat channel.
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task <bool> SendMessage(ChatMessage message)
        {
            if (IsSendingMessage)
            {
                return(false);
            }
            if (IsReloading)
            {
                WaitingMessage = message;
                ReloadEnded   -= SendMessage;
                ReloadEnded   += SendMessage;
                return(false);
            }
            IsSendingMessage = true;
            if (message.IsCommand)
            {
                CommandWorks(message);
            }
            else
            {
                ChatMessages.Add(message);
            }

            CheckLength();
            await UpdateChatMessages();

            IsSendingMessage = false;
            if (!(WaitingMessage is null))
            {
                WaitingMessage = null;
            }
            var sent = await GetMessages();

            ChatSent?.Invoke(this);
            return(sent);
        }
Ejemplo n.º 30
0
 private void _textChatCommand_NewMessageReceived(object sender, ChatMessage e)
 {
     ChatMessages.Add(e);
 }