コード例 #1
0
        public async Task <bool> ServerExists()
        {
            try
            {
                var request  = new GetCurrentItemRequest();
                var response = await _api.MakeRequest <GetCurrentItemRequest, GetCurrentItemResponse>(request).ConfigureAwait(false);

                if (response?.Success == true)
                {
                    _analytics.TrackServerConnect(true);
                    return(true);
                }
                else
                {
                    _analytics.TrackServerConnect(false);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _analytics.TrackServerConnect(false);
                Logger.Error($"Error pinging {_api.BaseUri} - {ex.Message}", ex);
                return(false);
            }
        }
コード例 #2
0
        public async Task <Item> GetCurrentItem()
        {
            if (IsDebugMode)
            {
                return(new MockItem());
            }

            // Popper has no endpoint to just get state, or any authentication to do a keep alive
            // so instead, make a call to "Get current item" which should respond but not alter
            // anything on popper
            var request  = new GetCurrentItemRequest();
            var response = await _api.MakeRequest <GetCurrentItemRequest, GetCurrentItemResponse>(request).ConfigureAwait(false);

            if (response?.Success == true &&
                response?.Data != null)
            {
                return(new Item(response.Data));
            }
            else
            {
                //TODO Error handling???
                Logger.Error($"Error requesting GetCurrentItem, responded with {response?.Code} and {response?.Messsage}");
                return(null);
            }
        }