コード例 #1
0
        private bool PollMessages(CallContext cntx, ulong lastId)
        {
            var            msgsvc = new SignalRMessageServiceProxy();
            DateTime       dt     = DateTime.UtcNow.AddHours(-config.TimeWindowInHours);
            QueryExpresion qexpr  = new QueryExpresion();

            qexpr.OrderTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "ID"
                },
                new QToken {
                    TkName = "desc"
                }
            });
            qexpr.FilterTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "ApplicationID == \"" + config.App.ID + "\" && ID > " + lastId + " && TimeStamp > " + dt.Ticks
                }
            });
            var msgs = msgsvc.QueryDatabaseLimited(cntx, new SignalRMessageSet(), qexpr, config.MaxBacklogMessages).ToArray();

            if (msgs.Length > 0)
            {
                LastMessageId          = (ulong)msgs[0].ID;
                IsLastMessageIdChanged = true;
                foreach (var e in from d in msgs orderby d.ID ascending select d)
                {
                    var smsg = ScaleoutMessage.FromBytes(e.MesssageData);
                    forwardMessage((ulong)e.ID, smsg);
                }
            }
            return(msgs.Length > 0);
        }
コード例 #2
0
        private void ProcOldMessages(CallContext cntx, SignalRMessageServiceProxy msgsvc)
        {
            var hsvc = new SignalRHostStateServiceProxy();
            var host = hsvc.LoadEntityByNature(cntx, config.HostName, config.App.ID).SingleOrDefault();

            if (host == null)
            {
                host = new SignalRHostState
                {
                    HostName      = config.HostName,
                    ApplicationID = config.App.ID,
                    LastMsgId     = 0
                };
                var x = hsvc.AddOrUpdateEntities(cntx, new SignalRHostStateSet(), new SignalRHostState[] { host });
                host = x.ChangedEntities[0].UpdatedItem;
            }
            DateTime       dt    = DateTime.UtcNow.AddHours(-config.TimeWindowInHours);
            QueryExpresion qexpr = new QueryExpresion();

            qexpr.OrderTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "ID"
                },
                new QToken {
                    TkName = "desc"
                }
            });
            qexpr.FilterTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "ApplicationID == \"" + config.App.ID + "\" && ID > " + host.LastMsgId + " && TimeStamp > " + dt.Ticks
                }
            });
            var msgs = msgsvc.QueryDatabaseLimited(cntx, new SignalRMessageSet(), qexpr, config.MaxBacklogMessages).ToArray();

            if (msgs.Length > 0)
            {
                host.LastMsgId         = msgs[0].ID;
                LastMessageId          = (ulong)host.LastMsgId;
                IsLastMessageIdChanged = true;
                foreach (var e in from d in msgs orderby d.ID ascending select d)
                {
                    OnReceived(0, (ulong)e.ID, ScaleoutMessage.FromBytes(e.MesssageData));
                }
            }
        }
コード例 #3
0
 private bool PollMessages(CallContext cntx, ulong lastId)
 {
     var msgsvc = new SignalRMessageServiceProxy();
     DateTime dt = DateTime.UtcNow.AddHours(-config.TimeWindowInHours);
     QueryExpresion qexpr = new QueryExpresion();
     qexpr.OrderTks = new List<QToken>(new QToken[] { 
         new QToken { TkName = "ID" },
         new QToken { TkName = "desc" }
     });
     qexpr.FilterTks = new List<QToken>(new QToken[] { 
         new QToken { TkName = "ApplicationID == \"" + config.App.ID + "\" && ID > " + lastId + " && TimeStamp > " + dt.Ticks }
     });
     var msgs = msgsvc.QueryDatabaseLimited(cntx, new SignalRMessageSet(), qexpr, config.MaxBacklogMessages).ToArray();
     if (msgs.Length > 0)
     {
         LastMessageId = (ulong)msgs[0].ID;
         IsLastMessageIdChanged = true;
         foreach (var e in from d in msgs orderby d.ID ascending select d)
         {
             var smsg = ScaleoutMessage.FromBytes(e.MesssageData);
             forwardMessage((ulong)e.ID, smsg);
         }
     }
     return msgs.Length > 0;
 }