private bool RemoveStreamListenerIfFinishedProcessing(IResourceFacade resource) { var listener = _listeners[resource.Id]; if (listener.IsFixtureEnded || resource.IsMatchOver) { _logger.DebugFormat("{0} is marked as ended - checking for stopping streaming", resource); var currentState = EventState.GetFixtureState(resource.Id); if (currentState != null && currentState.MatchStatus != MatchStatus.MatchOver) { _logger.DebugFormat("{0} is over but the MatchOver update has not been processed yet", resource); return(false); } _logger.InfoFormat("{0} is over. Listener will be removed", resource); if (RemoveStreamListener(resource.Id)) { EventState.RemoveFixture(resource.Id); } else { _logger.WarnFormat("Couldn't remove listener for matchOver fixture {0}", resource); } return(true); } return(false); }
/// <summary> /// Stops stream listener and removed all Adapter state + plugin state /// </summary> /// <param name="fixtureId"></param> public void RemoveFixtureState(string fixtureId) { //we don't want to have stream listener running while we remove it's state StopStreaming(fixtureId); RemoveStreamListener(fixtureId); StateManager.ClearState(fixtureId); EventState.RemoveFixture(fixtureId); StateProviderProxy.StateProvider.RemovePluginState(fixtureId); }
public virtual void UpdateCurrentlyAvailableFixtures(string sport, Dictionary <string, IResourceFacade> currentfixturesLookup) { var allFixturesForSport = _listeners.Where(x => string.Equals(x.Value.Sport, sport, StringComparison.Ordinal)); // deletedFixtures = allFixturesForSport \ resources var deletedFixtures = allFixturesForSport.Where(fixture => !currentfixturesLookup.ContainsKey(fixture.Key)); // existingFixtures = resources ^ allFixturesForSport var existingFixtures = allFixturesForSport.Where(fixture => currentfixturesLookup.ContainsKey(fixture.Key)); foreach (var fixture in deletedFixtures) { if (_listenerDisposingQueue.ContainsKey(fixture.Key)) { if (_listenerDisposingQueue[fixture.Key] >= LISTENER_DISPOSING_SAFE_GUARD) { _logger.InfoFormat("Fixture with fixtureId={0} was deleted from Connect fixture factory", fixture.Key); RemoveStreamListener(fixture.Key); EventState.RemoveFixture(fixture.Key); } else { _listenerDisposingQueue[fixture.Key] = _listenerDisposingQueue[fixture.Key] + 1; } } else { _listenerDisposingQueue.TryAdd(fixture.Key, 1); _logger.InfoFormat("Fixture with fixtureId={0} has been added to the disposing queue", fixture.Key); } } foreach (var fixture in existingFixtures) { if (_listenerDisposingQueue.ContainsKey(fixture.Key)) { int dummy; _listenerDisposingQueue.TryRemove(fixture.Key, out dummy); _logger.InfoFormat("Fixture with fixtureId={0} was marked as deleted, but it appered on Connect again", fixture.Key); } } SaveEventState(); }
public void RemoveFixtureEventState(string fixtureId) { EventState.RemoveFixture(fixtureId); }