Exemplo n.º 1
0
        public async Task StartRound(string roomId)
        {
            var room = await redis.GetAsync <Room>(roomId);

            int ix   = rng.Next(groundTruth.Count);
            var word = groundTruth[ix].Key;
            await Clients.Group(room.id).SendAsync("RoundStarted", word);

            _ = timers.RunLater(async(hubContext) => {
                try {
                    await Task.Delay(30 * 1000);
                    IRedisClientAsync redis = new RedisClient();
                    var options             = new List <string>((await redis.GetAsync <Room>(roomId)).answers.Values);
                    options.Add(groundTruth[ix].Value);
                    await hubContext.Clients.Group(room.id).SendAsync("SubmitDefnEnded", options);
                    _ = timers.RunLater(async(hubContext) => {
                        await Task.Delay(30 * 1000);
                        IRedisClientAsync redis = new RedisClient();
                        var chosen = 0;
                        await hubContext.Clients.Group(room.id).SendAsync("SubmitChoiceEnded", chosen);
                    });
                } catch (Exception ex) {
                    System.Console.Out.WriteLine(ex.Message);
                    System.Console.Out.WriteLine(ex.StackTrace);
                }
            });
            return;
        }