コード例 #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);
            }
        }
コード例 #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));
            }
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #5
0
ファイル: BellApiController.cs プロジェクト: DavidIQ/OnlyT
        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);
        }
コード例 #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);
        }