Example #1
0
        public TimerView(TimerResponse response)
        {
            BackgroundImage = "gamebg.png";
            InitializeComponent();
            _hunter_name     = response.hunter_username;
            _game_start_time = response.starttime;

            new Thread(() => TimerFunction(GameLogic.RunawayTime)).Start();
        }
Example #2
0
        public void CreateResponse()
        {
            var response = new TimerResponse
            {
                Id                      = "opaque, unique string",
                Duration                = TimeSpan.FromMinutes(10),
                Status                  = TimerStatus.Paused,
                Label                   = "chicken",
                TriggerTime             = DateTime.Parse("2019-09-12T19:10:00.083Z").ToUniversalTime(),
                CreatedTime             = DateTime.Parse("2019-09-12T19:00:00.083Z").ToUniversalTime(),
                UpdatedTime             = DateTime.Parse("2019-09-12T19:04:35.083Z").ToUniversalTime(),
                RemainingTimeWhenPaused = TimeSpan.FromMinutes(5).Add(TimeSpan.FromSeconds(25))
            };

            Assert.True(Utility.CompareJson(response, "CreateTimerResponse.json"));
        }
Example #3
0
        public async Task <ActionResult> StopTimer(BasicLocalRequest request)
        {
            if (!await this.IsAPITokenValid(request.ApiToken))
            {
                return(new BadRequestObjectResult("UnAuthorized"));
            }
            await this.HubContext.Clients.All.SendAsync("RecieveToggleTimer", "stop");

            var response = new TimerResponse()
            {
                Period       = Connector.Game.GameComplete ? 4 : (int)(Connector.GameScore.GameTime.Minutes / 12) + 1,
                TimerRunning = Connector.TimerRunning
            };

            //whenever you start or stop the timer, return back to the current period (to store for recording fouls) and whether the timer was already running
            return(new OkObjectResult(response));
        }
        public async IAsyncEnumerable <TimerResponse> StreamTimer(
            [EnumeratorCancellation] CancellationToken cancellationToken,
            TimerRequest req
            )
        {
            AppContext.SetSwitch(
                "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            var channel  = GrpcChannel.ForAddress("http://localhost:8080");
            var client   = new Protoclock.clockService.clockServiceClient(channel);
            var timerReq = new timerRequest();

            timerReq.Length  = req.Length;
            timerReq.Message = req.Message;

            using var call = client.timer(timerReq);
            while (await call.ResponseStream.MoveNext(cancellationToken))
            {
                Console.WriteLine("Timer Time Remaining: " + call.ResponseStream.Current.TimeLeft);
                var response = new TimerResponse();
                response.TimeRemaining = call.ResponseStream.Current.TimeLeft;
                response.Message       = call.ResponseStream.Current.Message;
                yield return(response);
            }
        }