예제 #1
0
        private async Task SaveCapabilities(string deviceId, SessionCapabilities capabilities)
        {
            var path = GetCapabilitiesFilePath(deviceId);
            Directory.CreateDirectory(Path.GetDirectoryName(path));

            await _capabilitiesLock.WaitAsync().ConfigureAwait(false);

            try
            {
                _jsonSerializer.SerializeToFile(capabilities, path);
            }
            finally
            {
                _capabilitiesLock.Release();
            }
        }
예제 #2
0
        /// <summary>
        /// Reports the capabilities.
        /// </summary>
        /// <param name="sessionId">The session identifier.</param>
        /// <param name="capabilities">The capabilities.</param>
        public void ReportCapabilities(string sessionId, SessionCapabilities capabilities)
        {
            var session = GetSession(sessionId);

            ReportCapabilities(session, capabilities, true);
        }
예제 #3
0
        private async void ReportCapabilities(SessionInfo session,
            SessionCapabilities capabilities,
            bool saveCapabilities)
        {
            session.PlayableMediaTypes = capabilities.PlayableMediaTypes;
            session.SupportedCommands = capabilities.SupportedCommands;

            if (!string.IsNullOrWhiteSpace(capabilities.MessageCallbackUrl))
            {
                var controller = session.SessionController as HttpSessionController;

                if (controller == null)
                {
                    session.SessionController = new HttpSessionController(_httpClient, _jsonSerializer, session, capabilities.MessageCallbackUrl, this);
                }
            }

            EventHelper.FireEventIfNotNull(CapabilitiesChanged, this, new SessionEventArgs
            {
                SessionInfo = session

            }, _logger);

            if (saveCapabilities)
            {
                await SaveCapabilities(session.DeviceId, capabilities).ConfigureAwait(false);
            }
        }
예제 #4
0
        /// <summary>
        /// Reports the capabilities.
        /// </summary>
        /// <param name="sessionId">The session identifier.</param>
        /// <param name="capabilities">The capabilities.</param>
        public void ReportCapabilities(string sessionId, SessionCapabilities capabilities)
        {
            var session = GetSession(sessionId);

            session.PlayableMediaTypes = capabilities.PlayableMediaTypes;
            session.SupportedCommands = capabilities.SupportedCommands;
        }