Beispiel #1
0
 private MessageData SaveFile(MessageData messageData)
 {
     messageData = _contentDatabase.Store(messageData);
     // the object is going to be typecasted to ReceiveMessageData
     // to be sent to clients, so make filedata null because the filedata
     // will continue to be in memory despite the typecasting
     messageData.FileData = null;
     return(messageData);
 }
        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);
            }
        }
Beispiel #3
0
 private MessageData Store(MessageData messageData)
 {
     return(_contentDatabase.Store(messageData));
 }