Exemplo n.º 1
0
        public async Task SendStartGame(string group, int timeoutseconds, string seperator, string words)
        {
            try
            {
                // set the owner
                GroupDetails.SetOwner(group, Context.ConnectionId);

                // add words
                if (!GroupDetails.AddRoundDetails(group, words.Split(seperator), timeoutseconds))
                {
                    await Clients.Group(group).SendAsync("ReceiveMessage", "failed to set game details");

                    return;
                }

                // mark that this group has already started
                if (!GroupDetails.SetGroupStarted(group, isstarted: true))
                {
                    await Clients.Group(group).SendAsync("ReceiveMessage", $"failed to start game");

                    return;
                }

                // notify everyone else to start game
                await Clients.OthersInGroup(group).SendAsync("ReceiveStartGame");
            }
            catch (Exception e)
            {
                await Clients.Group(group).SendAsync("ReceiveMessage", $"failed to start game: {e.Message}");
            }
        }