Ejemplo n.º 1
0
        private void TimerTick(object sender, System.EventArgs e)
        {
            var now = _dateTimeService.Now();

            if (!_stopwatch.IsRunning)
            {
                // not yet started the meeting...
                if (now.Minute % 15 == 0)
                {
                    // start on the nearest quarter hour...
                    _stopwatch.Start();
                    _nextStartTime = now.TimeOfDay.Add(TimeSpan.FromMinutes(5));
                }

                return;
            }

            var status = _timerService.GetStatus();

            CheckIsCurrentTalk(status);

            if (_nextStartTime != null && now.TimeOfDay > _nextStartTime)
            {
                // Start the talk timer...
                CheckNotRunning(status);

                if (status.TalkId != null)
                {
                    _timerService.StartTalkTimerFromApi(status.TalkId.Value);
                }

                _nextStartTime = null;
                _nextStopTime  = now.TimeOfDay.Add(TimeSpan.FromSeconds(status.TargetSeconds));

                return;
            }

            if (_nextStopTime != null && now.TimeOfDay > _nextStopTime)
            {
                // Stop the talk timer...
                CheckIsRunning(status);

                if (status.TalkId != null)
                {
                    _timerService.StopTalkTimerFromApi(status.TalkId.Value);
                }

                _nextStopTime  = null;
                _nextStartTime = CalculateNextStartTime(status, now);

                if (_nextStartTime == null)
                {
                    // all done
                    _stopwatch.Stop();
                    _timer.Stop();
                }
            }
        }
Ejemplo 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));
            }
        }