Ejemplo n.º 1
0
        /// <summary>
        /// This is used to verify if the user that has logged in
        /// is the same that before, if not this will Reject every query in the Queue
        /// and clear all subscriptions, otherwise this will replay the Queue if it is waiting.
        /// </summary>
        internal override void OnUserLoggedIn(object sender, UserLoggedInEvent e)
        {
            if (previousKUID != e.Kuid)
            {
                if (AutoRecover &&
                    QueryReplayer.WaitLoginToReplay)
                {
                    QueryReplayer.RejectAllQueries(new UnauthorizeException("Request submitted by another user"));
                    QueryReplayer.Lock = false;
                    QueryReplayer.WaitLoginToReplay = false;
                }

                SubscriptionRecoverer.Clear();
            }
            else
            {
                if (AutoRecover &&
                    QueryReplayer.WaitLoginToReplay)
                {
                    QueryReplayer.ReplayQueries();
                    QueryReplayer.Lock = false;
                    QueryReplayer.WaitLoginToReplay = false;
                }

                SubscriptionRecoverer.RenewSubscriptions();
            }
            previousKUID = e.Kuid;
        }
Ejemplo n.º 2
0
 internal override void OnUserLoggedOut()
 {
     if (AutoRecover &&
         QueryReplayer.WaitLoginToReplay
         )
     {
         QueryReplayer.RejectAllQueries(new UnauthorizeException("Request submitted by another user"));
         QueryReplayer.Lock = false;
         QueryReplayer.WaitLoginToReplay = false;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// This will check the token validity,
        /// and chose what to do before replaying the Queue
        /// </summary>
        internal override async Task Recover()
        {
            if (!AutoRecover)
            {
                return;
            }

            if (await TokenVerifier.IsTokenValid())
            {
                QueryReplayer.ReplayQueries();
                SubscriptionRecoverer.RenewSubscriptions();
                return;
            }

            if (QueryReplayer.Lock)
            {
                QueryReplayer.ReplayQueries((obj) =>
                                            obj["controller"]?.ToString() == "auth" &&
                                            (obj["action"].ToString() == "login" ||
                                             obj["action"].ToString() == "logout"), false);
            }
        }
Ejemplo n.º 4
0
 internal virtual void InitComponents()
 {
     QueryReplayer         = new QueryReplayer(this, kuzzle);
     SubscriptionRecoverer = new SubscriptionRecoverer(this, kuzzle);
     TokenVerifier         = new TokenVerifier(this, kuzzle);
 }
Ejemplo n.º 5
0
 public QueryReplayerTest()
 {
     mockedNetworkProtocol  = new Mock <AbstractProtocol>();
     testableOfflineManager = new TestableOfflineManager(mockedNetworkProtocol.Object, kuzzle);
     queryReplayer          = new QueryReplayer(testableOfflineManager, kuzzle.GetKuzzle());
 }