Example #1
0
        private async Task HandleResetGameCommand(bool gameTerminate)
        {
            // resets the game
            availableIcons = new bool[6] {
                true, true, true, true, true, true
            };
            game.Reset();

            command = gameTerminate ? "Terminate" : "ResetSuccess";

            // send the success message to playing players
            foreach (WebSocket socket in manager.GetPlayingSockets())
            {
                await SendJSON(socket, new
                {
                    command
                    // no need to send the reset gameView. it is done in client-side
                });
            }

            // reconnect the sockets of players who finished the game to maintain the
            // order with sockets that already were waiting in the lobby
            manager.ReconnectTheConnectionOfOldPlayers();
        }