/// <summary> /// Disconnects the player that was passed to the Attach method /// </summary> public void Detach() { if (IsAttached) { if (reportTimer != null) { #if SILVERLIGHT reportTimer.Dispose(); #else reportTimer.Cancel(); #endif reportTimer = null; } if (pollingTimer != null) { #if SILVERLIGHT pollingTimer.Dispose(); #else pollingTimer.Cancel(); #endif pollingTimer = null; } DetachEvents(); Player = null; AdaptiveMonitor = null; streamLoadedLog = null; qualityReportAggregator = null; downloadErrorReportAggregator = null; LoggingSources.Clear(); IsAttached = false; } }
/// <summary> /// Connects a player that needs to be monitored /// </summary> public void Attach(IPlayerMonitor player, IAdaptiveMonitor adaptiveMonitor, IEnvironmentMonitor environmentMonitor, IEdgeServerMonitor edgeServerMonitor) { if (!IsAttached) { IsAttached = true; if (player == null) { throw new ArgumentNullException("player"); } streamLoadedLog = null; EdgeServerMonitor = edgeServerMonitor; AdaptiveMonitor = adaptiveMonitor; Player = player; EnvironmentMonitor = environmentMonitor; if (Configuration.TrackQuality) { qualityReportAggregator = new QualityReportAggregator(Configuration.QualityConfig); } if (Configuration.TrackDownloadErrors) { downloadErrorReportAggregator = new DownloadErrorReportAggregator(); } AttachEvents(); if (Configuration.PollingInterval > TimeSpan.Zero) { #if SILVERLIGHT pollingTimer = new Timer(pollingTimer_Tick, null, Configuration.PollingInterval, Configuration.PollingInterval); #else pollingTimer = ThreadPoolTimer.CreatePeriodicTimer(pollingTimer_Tick, Configuration.PollingInterval); #endif } if (Configuration.AggregationInterval > TimeSpan.Zero) { #if SILVERLIGHT reportTimer = new Timer(reportTimer_Tick, null, Configuration.AggregationInterval, Configuration.AggregationInterval); #else reportTimer = ThreadPoolTimer.CreatePeriodicTimer(reportTimer_Tick, Configuration.AggregationInterval); #endif } } }