示例#1
0
        public async Task <LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
        {
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            //Version Check
            var options = new HttpRequestOptions()
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/Util/NPVR/VersionCheck?sid={1}", baseUrl, Sid)
            };

            bool   upgradeAvailable;
            string serverVersion;

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                var versionCheckResponse = new VersionCheckResponse(stream, _jsonSerializer);

                upgradeAvailable = versionCheckResponse.UpdateAvailable();
                serverVersion    = versionCheckResponse.ServerVersion();
            }


            //Tuner information
            var optionsTuner = new HttpRequestOptions()
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/Util/Tuner/Stat?sid={1}", baseUrl, Sid)
            };

            List <LiveTvTunerInfo> tvTunerInfos;

            using (var stream = await _httpClient.Get(optionsTuner).ConfigureAwait(false))
            {
                var tuners = new TunerResponse(stream, _jsonSerializer);
                tvTunerInfos = tuners.LiveTvTunerInfos();
            }

            return(new LiveTvServiceStatusInfo
            {
                HasUpdateAvailable = upgradeAvailable,
                Version = serverVersion,
                Tuners = tvTunerInfos
            });
        }
示例#2
0
        public async Task <LiveTvServiceStatusInfo> GetStatusInfoAsync(CancellationToken cancellationToken)
        {
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            //Version Check
            var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);

            bool   upgradeAvailable;
            string serverVersion;

            await using (var stream = await httpClient.GetStreamAsync(string.Format("{0}/service?method=setting.version&sid={1}", baseUrl, Sid), cancellationToken))
            {
                var versionCheckResponse = new VersionCheckResponse(stream, _jsonSerializer);

                upgradeAvailable = versionCheckResponse.UpdateAvailable();
                serverVersion    = versionCheckResponse.ServerVersion();
            }


            //Tuner information
            List <LiveTvTunerInfo> tvTunerInfos;

            using (var stream = await httpClient.GetStreamAsync(string.Format("{0}/service/method=system.status?sid={1}", baseUrl, Sid), cancellationToken).ConfigureAwait(false))
            {
                var tuners = new TunerResponse(stream, _jsonSerializer);
                tvTunerInfos = tuners.LiveTvTunerInfos();
            }

            return(new LiveTvServiceStatusInfo
            {
                HasUpdateAvailable = upgradeAvailable,
                Version = serverVersion,
                Tuners = tvTunerInfos
            });
        }