internal void StateChangeListener(object sender, ProtocolState state) { if (state == ProtocolState.Open && previousState == ProtocolState.Reconnecting) { kuzzle.GetEventHandler().DispatchReconnected(); Task.Run(async() => { QueryReplayer.WaitLoginToReplay = true; await Recover(); }); } previousState = state; }
/// <summary> /// Remove every query that satisfies the predicate /// </summary> /// <returns>How many items where removed.</returns> public int Remove(Predicate <JObject> predicate) { queueSemaphore.Wait(); try { if (queue.Count > 0) { Predicate <TimedQuery> timedQueryPredicate = timedQuery => predicate(timedQuery.Query); int itemsRemoved = queue.RemoveAll(timedQueryPredicate); if (queue.Count == 0 && currentlyReplaying) { Lock = false; currentlyReplaying = false; WaitLoginToReplay = false; kuzzle.GetEventHandler().DispatchQueueRecovered(); } return(itemsRemoved); } } finally { queueSemaphore.Release(); } return(0); }
public SubscriptionRecoverer(IOfflineManager offlineManager, IKuzzle kuzzle) { this.realtimeController = kuzzle.GetRealtime(); kuzzle.GetEventHandler().Subscription += OnSubscriptionEvent; }