public StreamListener(IResourceFacade resource, IAdapterPlugin platformConnector, IEventState eventState, IStateManager stateManager, ISettings settings)
        {
            if (resource == null)
            {
                throw new ArgumentException("Resource information cannot be null");
            }

            if (resource.Content == null)
            {
                throw new Exception("Resource does not contain any content");
            }


            _logger.DebugFormat("Instantiating listener for {0} with sequence={1}", resource, resource.Content.Sequence);

            _lockTimeout       = settings.ProcessingLockTimeOutInSecs;
            _resource          = resource;
            _platformConnector = platformConnector;
            _eventState        = eventState;
            _stateManager      = stateManager;
            _settings          = settings;

            _currentSequence = resource.Content.Sequence;
            _lastSequenceProcessedInSnapshot = -1;

            _hasRecoveredFromError     = true;
            _isFirstSnapshotProcessed  = false;
            _isProcessingFirstSnapshot = false;
            _performingDelayedStop     = false;

            _marketsRuleManager = stateManager.CreateNewMarketRuleManager(resource.Id);

            FixtureId = resource.Id;
            Sport     = resource.Sport;
            SequenceOnStreamingAvailable = _currentSequence;

            IsStreaming  = false;
            IsConnecting = false;
            IsDisposing  = false;
            IsErrored    = false;
            IsIgnored    = false;
            IsStopping   = false;

            var fixtureState = _eventState.GetFixtureState(resource.Id);

            IsFixtureEnded   = fixtureState != null ? fixtureState.MatchStatus == MatchStatus.MatchOver : _resource.IsMatchOver;
            IsFixtureSetup   = (_resource.MatchStatus == MatchStatus.Setup || _resource.MatchStatus == MatchStatus.Ready);
            IsFixtureDeleted = false;
            IsInPlay         = fixtureState != null ? fixtureState.MatchStatus == MatchStatus.InRunning : _resource.MatchStatus == MatchStatus.InRunning;
            _currentEpoch    = fixtureState != null ? fixtureState.Epoch : -1;

            _Stats = StatsManager.Instance[string.Concat("adapter.core.sport.", resource.Sport)].GetHandle();

            SetupListener();
            _logger.DebugFormat("Listener instantiated for {0}", resource);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="platformConnector"></param>
        /// <param name="resource"></param>
        /// <param name="stateManager"></param>
        /// <param name="suspensionManager"></param>
        /// <param name="streamHealthCheckValidation"></param>
        /// <param name="fixtureValidation"></param>
        public StreamListenerActor(
            ISettings settings,
            IAdapterPlugin platformConnector,
            IResourceFacade resource,
            IStateManager stateManager,
            ISuspensionManager suspensionManager,
            IStreamHealthCheckValidation streamHealthCheckValidation,
            IFixtureValidation fixtureValidation)
        {
            try
            {
                _isInitializing = true;

                _settings                    = settings ?? throw new ArgumentNullException(nameof(settings));
                _platformConnector           = platformConnector ?? throw new ArgumentNullException(nameof(platformConnector));
                _resource                    = resource ?? throw new ArgumentNullException(nameof(resource));
                _stateManager                = stateManager ?? throw new ArgumentNullException(nameof(stateManager));
                _suspensionManager           = suspensionManager ?? throw new ArgumentNullException(nameof(suspensionManager));
                _marketsRuleManager          = _stateManager.CreateNewMarketRuleManager(resource.Id);
                _streamHealthCheckValidation = streamHealthCheckValidation ?? throw new ArgumentNullException(nameof(streamHealthCheckValidation));
                _fixtureValidation           = fixtureValidation ?? throw new ArgumentNullException(nameof(fixtureValidation));
                _fixtureId                   = _resource.Id;
                _resourceActor               = Context.ActorOf(
                    Props.Create(() => new ResourceActor(Self, _resource)),
                    ResourceActor.ActorName);
                _streamHealthCheckActor = Context.ActorOf(
                    Props.Create(() => new StreamHealthCheckActor(_resource, _settings, _streamHealthCheckValidation)),
                    StreamHealthCheckActor.ActorName);
                _streamStatsActor = Context.ActorOf(
                    Props.Create(() => new StreamStatsActor()),
                    StreamStatsActor.ActorName);

                Context.Parent.Tell(new NewStreamListenerActorMsg {
                    FixtureId = _resource.Id, Sport = _resource.Sport
                });

                Initialize();
            }
            catch (Exception ex)
            {
                _logger.Error(
                    $"Stream Listener instantiation failed for {_resource} - exception - {ex}");
                _erroredException = ex;
                Become(Errored);
            }
        }
        public StreamListener(IResourceFacade resource, IAdapterPlugin platformConnector, IEventState eventState, IStateManager stateManager,ISettings settings)
        {
            if (resource == null)
                throw new ArgumentException("Resource information cannot be null");

            if (resource.Content == null)
                throw new Exception("Resource does not contain any content");


            _logger.DebugFormat("Instantiating listener for {0} with sequence={1}", resource, resource.Content.Sequence);

            _lockTimeout = settings.ProcessingLockTimeOutInSecs;
            _resource = resource;
            _platformConnector = platformConnector;
            _eventState = eventState;
            _stateManager = stateManager;
            _settings = settings;

            _currentSequence = resource.Content.Sequence;
            _lastSequenceProcessedInSnapshot = -1;
            
            _hasRecoveredFromError = true;
            _isFirstSnapshotProcessed = false;
            _isProcessingFirstSnapshot = false;
            _performingDelayedStop = false;

            _marketsRuleManager = stateManager.CreateNewMarketRuleManager(resource.Id);

            FixtureId = resource.Id;
            Sport = resource.Sport;
            SequenceOnStreamingAvailable = _currentSequence;

            IsStreaming = false;
            IsConnecting = false;
            IsDisposing = false;
            IsErrored = false;
            IsIgnored = false;
            IsStopping = false;

            var fixtureState = _eventState.GetFixtureState(resource.Id);

            IsFixtureEnded = fixtureState != null ? fixtureState.MatchStatus == MatchStatus.MatchOver : _resource.IsMatchOver;
            IsFixtureSetup = (_resource.MatchStatus == MatchStatus.Setup || _resource.MatchStatus == MatchStatus.Ready);
            IsFixtureDeleted = false;
            IsInPlay = fixtureState != null ? fixtureState.MatchStatus == MatchStatus.InRunning : _resource.MatchStatus == MatchStatus.InRunning;
            _currentEpoch = fixtureState != null ? fixtureState.Epoch : -1;
            
            _Stats = StatsManager.Instance[string.Concat("adapter.core.sport.", resource.Sport)].GetHandle();

            SetupListener();
            _logger.DebugFormat("Listener instantiated for {0}", resource);

        }