コード例 #1
0
        private void UpdateChatContext(ReceiveMessageData receiveMessageData)
        {
            if (receiveMessageData.ReplyThreadId != -1)
            {
                var chatContext = _allMessages.FirstOrDefault(chatContext =>
                                                              chatContext.ThreadId == receiveMessageData.ReplyThreadId);
                switch (receiveMessageData.Event)
                {
                case MessageEvent.NewMessage:
                    Trace.WriteLine("[ChatContextServer] Event is NewMessage, Adding message to existing Thread");
                    chatContext.MsgList.Add(receiveMessageData);
                    chatContext.NumOfMessages++;
                    break;

                case MessageEvent.Star:
                    Trace.WriteLine("[ChatContextServer] Event is Star, Starring message in existing Thread");
                    StarMessage(receiveMessageData, chatContext);
                    break;

                case MessageEvent.Update:
                    Trace.WriteLine("[ChatContextServer] Event is Update, Updating message in existing Thread");
                    UpdateMessage(receiveMessageData, chatContext);
                    break;

                default:
                    Debug.Assert(false, "[ChatContextServer] Unkown Event");
                    return;
                }

                _contentDatabase.UpdateChatContext(chatContext.ThreadId, chatContext);
            }
            else
            {
                Trace.WriteLine("[ChatContextServer] Creating a new ChatContext and adding message to it");
                var chatContext = new ChatContext();
                chatContext.CreationTime  = receiveMessageData.SentTime;
                chatContext.NumOfMessages = 1;
                chatContext.MsgList       = new List <ReceiveMessageData>();
                chatContext.MsgList.Add(receiveMessageData);
                _contentDatabase.Store(chatContext);
                _allMessages.Add(chatContext);
            }
        }
コード例 #2
0
 public void UpdateChatContext(int id, ChatContext chatContext)
 {
     _chatContexts[id] = chatContext;
 }
コード例 #3
0
 public void Store(ChatContext chatContext)
 {
     chatContext.ThreadId = IdGenerator.getChatContextId();
     _chatContexts[chatContext.ThreadId] = chatContext;
 }