/// <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; }
internal override void OnUserLoggedOut() { if (AutoRecover && QueryReplayer.WaitLoginToReplay ) { QueryReplayer.RejectAllQueries(new UnauthorizeException("Request submitted by another user")); QueryReplayer.Lock = false; QueryReplayer.WaitLoginToReplay = false; } }
public void SuccessRejectAllQueries() { testableOfflineManager.MaxQueueSize = -1; queryReplayer.Lock = false; Assert.True(queryReplayer.Enqueue(JObject.Parse("{requestId: '1', controller: 'foo', action: 'bar'}"))); Assert.True(queryReplayer.Enqueue(JObject.Parse("{requestId: '2', controller: 'bar', action: 'foor'}"))); Assert.True(queryReplayer.Enqueue(JObject.Parse("{requestId: '3', controller: 'foobar', action: 'foobar'}"))); Assert.True(queryReplayer.Enqueue(JObject.Parse("{requestId: '4', controller: 'barfoo', action: 'foobar'}"))); Assert.True(queryReplayer.Enqueue(JObject.Parse("{requestId: '5', controller: 'foobar', action: 'barfoo'}"))); Assert.True(queryReplayer.Enqueue(JObject.Parse("{requestId: '6', controller: 'barfoo', action: 'barfoo'}"))); Assert.Equal(6, queryReplayer.Count); queryReplayer.RejectAllQueries(new Exception("Some exception")); kuzzle.mockedKuzzle.Verify((obj) => obj.GetRequestById(It.IsAny <string>()), Times.Exactly(6)); Assert.Equal(0, queryReplayer.Count); }