Beispiel #1
0
        /// <summary>
        /// Adds a message to the chat.
        /// If the chat parameter is null we try to load the chat from the chatManager.
        /// </summary>
        /// <param name="message">The message to save</param>
        /// <param name="chat">Optional the chat to save it to</param>
        public void AddMessage(LocalChatMessage message, IChat chat = null)
        {
            if (chat == null)
            {
                chat = GetChat(message.chatId);
            }
            if (chat.lastMessageIndex < message.id.IdfromSource)
            {
                chat.lastMessageIndex = message.id.IdfromSource;
            }


            message.LocalMessageChatIndex = chat.MessageCount;

            chat.MessageCount++;
            MessageManager.SaveMessage(message);
        }
Beispiel #2
0
 public void SaveMessage(LocalChatMessage message)
 {
     FileController.AppendLineAs <LocalChatMessage>(FileName(message.chatId, message.id.IdfromSource), message);
 }
Beispiel #3
0
 public LocalChatMessage(LocalChatMessage message) : this(message.content, message.timetamp, message.refs, message.id, message.type, message.States)
 {
 }
Beispiel #4
0
 public void DeleteMessage(LocalChatMessage message)
 {
     DataController.Instance.RemoveFromFile <ChatMessage>(
         $"messages/{message.id.Source}",
         (m) => m.Equals(message));
 }