Esempio n. 1
0
 public void SendMessage(ISender sender, string content, List <IAttachment> attachments, MessageType messageType = MessageType.Normal)
 {
     if (Client != null && Client.IsCanChat)
     {
         ChatMessageContainer container = new ChatMessageContainer(MessageFactory.Create(sender, content, attachments, messageType));
         Client?.SendChatMessage(container.ToJSON());
     }
 }
Esempio n. 2
0
        private void OnMessagesReceived(string json)
        {
            ChatMessageContainer container = new ChatMessageContainer();

            container.LoadFromJSON(json);
            if (container.messages != null && container.messages.Count > 0)
            {
                List <ChatMessage> containerMessages = container.messages;
                containerMessages = containerMessages.OrderByDescending(m => m.GetTime()).ToList();
                messages.InsertRange(0, containerMessages);
                while (messages.Count > MaxCount)
                {
                    messages.RemoveAt(messages.Count - 1);
                }
                RavenhillEvents.OnChatMessagesReceived(containerMessages);
            }
        }