Exemplo n.º 1
0
        private void HandleRequestForClockWebPage(HttpListenerRequest request, HttpListenerResponse response)
        {
            if (_optionsService.Options.IsWebClockEnabled)
            {
                _apiThrottler.CheckRateLimit(ApiRequestType.ClockPage, request);

                ClockWebPageController controller = new ClockWebPageController();
                controller.HandleRequestForWebPage(response);
            }
        }
Exemplo n.º 2
0
        private void HandleDeleteTimersApi(HttpListenerRequest request, HttpListenerResponse response)
        {
            CheckSegmentLength(request, 5);

            _apiThrottler.CheckRateLimit(ApiRequestType.TimerControlStop, request);

            if (int.TryParse(request.Url.Segments[4], out var talkId))
            {
                WriteResponse(response, _timerService.StopTalkTimerFromApi(talkId));
            }
        }
Exemplo n.º 3
0
        private void HandleApiVersionRequest(HttpListenerRequest request, HttpListenerResponse response)
        {
            CheckMethodGet(request);

            _apiThrottler.CheckRateLimit(ApiRequestType.Version, request);

            var v = new ApiVersion {
                LowVersion = OldestSupportedApiVer, HighVersion = CurrentApiVer
            };

            WriteResponse(response, v);
        }
Exemplo n.º 4
0
        public void Handler(
            HttpListenerRequest request,
            HttpListenerResponse response,
            int oldestSupportedApiVersion,
            int currentApiVersion)
        {
            CheckMethodGet(request);
            CheckSegmentLength(request, 4);

            _apiThrottler.CheckRateLimit(ApiRequestType.System, request);

            // segments: "/" "api/" "v1/" "system/"
            WriteResponse(response, GetSystemData(oldestSupportedApiVersion, currentApiVersion));
        }
Exemplo n.º 5
0
        public void Handler(HttpListenerRequest request, HttpListenerResponse response)
        {
            CheckMethodPost(request);
            CheckSegmentLength(request, 4);

            _apiThrottler.CheckRateLimit(ApiRequestType.Bell, request);

            var responseData = new BellResponseData();

            // segments: "/" "api/" "v1/" "bell/"
            if (!_bellService.IsPlaying)
            {
                responseData.Success = true;
                _bellService.Play(_optionsService.Options.BellVolumePercent);
            }
            else
            {
                responseData.Success = false;
            }

            WriteResponse(response, responseData);
        }
Exemplo n.º 6
0
        public void Handler(HttpListenerRequest request, HttpListenerResponse response)
        {
            CheckMethodGet(request);
            CheckSegmentLength(request, 4);

            _apiThrottler.CheckRateLimit(ApiRequestType.DateTime, request);

            // segments: "/" "api/" "v1/" "datetime/"
            // system clock
            var dt = DateTime.Now;

            var lt = new LocalTime
            {
                Year   = dt.Year,
                Month  = dt.Month,
                Day    = dt.Day,
                Hour   = dt.Hour,
                Min    = dt.Minute,
                Second = dt.Second
            };

            WriteResponse(response, lt);
        }