Beispiel #1
0
        public static bool AddMessage(Message message, string roomName, string password)
        {
            Room room = GetRoom(roomName, password);
            if (room == null)
            {
                return false;
            }

            List<Message> messages = room.Messages ?? new List<Message>();
            messages.Insert(0, message);

            while (messages.Count > Constants.MaximumMessageInDatabase)
            {
                Message poppedMessage = messages.ElementAt(Constants.MaximumMessageInDatabase);
                messages.RemoveAt(Constants.MaximumMessageInDatabase);
                ArchiveMessage(poppedMessage, roomName);
            }

            room.Messages = messages;
            room.DateLastPost = DateTime.Now;
            return SaveRoom(room);
        }
Beispiel #2
0
        public void RelayMessage(string userName, string roomName, Message message)
        {
            var user = GetUser(userName);
            if (user == null) return;

            var newMessage = new Message(ParseMessage(message.Content), message.UserId, message.GravatarLink);
            var password = GetRoomPasswordForUser(user, roomName);

            ClientNotifier.ReceiveMessage(roomName, message);
            DatabaseManager.AddMessage(newMessage, roomName, password);
        }
Beispiel #3
0
 private static void ArchiveMessage(Message message, string roomName)
 {
     //Haha we don't archive stuff. Your data has been lost.
 }
Beispiel #4
0
 public void ReceiveMessage(string roomName, Message message)
 {
     _clients.ReceiveMessage(message, roomName);
 }