public override void HandleMessage(XmppStream stream, Message message, XmppHandlerContext context)
        {
            if (!message.HasTo) return;
            if (archiveStore == null)
            {
                archiveStore = new DbMessageArchive();
                var properties = new Dictionary<string, string>(1);
                properties.Add("connectionStringName", "core");
                archiveStore.Configure(properties);
            }
            if (archiveStore.GetMessageLogging(message.From, message.To))
            {
                if (!string.IsNullOrEmpty(message.Body) ||
                    !string.IsNullOrEmpty(message.Subject) ||
                    !string.IsNullOrEmpty(message.Thread) ||
                    message.Html != null)
                {
                    var flush = false;
                    lock (messageBuffer)
                    {
                        //Add xdelay
                        if (message.XDelay == null)
                        {
                            message.XDelay = new Delay();
                            message.XDelay.Stamp = DateTime.UtcNow;
                        }
                        messageBuffer.Add(message);

                        flush = BUFFER_SIZE <= messageBuffer.Count;
                    }
                    if (flush) FlushMessageBuffer();
                }
            }
        }
 public override void OnRegister(IServiceProvider serviceProvider)
 {
     archiveStore = ((StorageManager)serviceProvider.GetService(typeof(StorageManager))).GetStorage<DbMessageArchive>("archive");
 }
Exemplo n.º 3
0
        public DbMsgArchiveTest()
		{
			store = new DbMessageArchive();
            store.Configure(GetConfiguration());
		}