internal IPromise <Nothing> QueueMessage(PlayerHandle sender, string recipientName, string messageText)
        {
            try
            {
                Log.Debug("Offline message queue: from {sender} to {recipientName}", sender.Digest, recipientName);
                var recipient  = this.characterService.Find(recipientName);
                var dateString = DateTime.Now.ToShortDateString();
                var timeString = DateTime.Now.ToShortTimeString();

                var message = new OfflineMessage
                {
                    SenderId    = sender.Id,
                    RecepientId = recipient.Id,
                    Message     = String.Format("{0} {1}: {2}", dateString, timeString, messageText),
                };

                this.db.Write((c) => c.OfflineMessageInsert(message));
                return(sender.Stream.Write(Responses.ServerPrivateChatMessage(
                                               recipient.Name,
                                               recipient.Id,
                                               Strings.PLAYER_IS_OFFLINE_MESSAGES_WILL_BE_DELIVERED
                                               )));
            }
            catch (Database.NotFoundException)
            {
                Log.Warning("Failed to queue offline message from {sender} - {recipientName} not found!", sender.Digest, recipientName);
                return(Nothing.Resolved());
            }
        }
Esempio n. 2
0
 internal void OfflineMessageInsert(OfflineMessage msg)
 {
     this.connection.Insert(msg);
 }