Пример #1
0
        private void HandleUpdatedDataBaseClients(object sender, MessageContainer msgContainer)
        {
            switch (msgContainer.Identifier)
            {
            case MsgType.UpdatedDataBaseClients:
                if (((JObject)msgContainer.Payload).ToObject(typeof(UpdatedDataBaseClients)) is UpdatedDataBaseClients messageRequest)
                {
                    ApplicationDispatcherHelper.BeginInvoke(() => UpdatedDataBaseClientsEvent?.Invoke(messageRequest.ClientsList));
                }

                break;

            case MsgType.UpdatedDataBaseMessages:
                if (((JObject)msgContainer.Payload).ToObject(typeof(UpdatedDataBaseMessages)) is UpdatedDataBaseMessages messageRequest1)
                {
                    var personalMessagesList = new List <DataBaseMessage>();
                    foreach (DataBaseMessage message in messageRequest1.MessagesList)
                    {
                        if (message.ClientFrom == Login || message.ClientTo == Login || message.ClientTo == "CommonChat")
                        {
                            personalMessagesList.Add(message);
                        }
                    }

                    ApplicationDispatcherHelper.BeginInvoke(() => UpdatedDataBaseMessagesEvent?.Invoke(personalMessagesList));
                }

                break;

            case MsgType.UpdatedDataBaseEvents:
                if (((JObject)msgContainer.Payload).ToObject(typeof(UpdatedDataBaseEvents)) is UpdatedDataBaseEvents messageRequest2)
                {
                    ApplicationDispatcherHelper.BeginInvoke(() => UpdatedDataBaseEventsEvent?.Invoke(messageRequest2.EventsList));
                }

                break;
            }
        }
Пример #2
0
 public void HandleUpdatedUsersList(List <string> activeUsersList, List <string> notActiveUsersList)
 {
     ApplicationDispatcherHelper.BeginInvoke(() => UpdatedUsersListEvent?.Invoke(activeUsersList, notActiveUsersList));
 }
Пример #3
0
 private void HandleMessageReceived(object sender, MessageReceivedEventArgs state)
 {
     ApplicationDispatcherHelper.BeginInvoke(() => MessageReceivedEvent?.Invoke(state));
 }