public void GenerateGame(String numOfRows, String numOfCols,
                                 String nameOfMaze)
        {
            string command;

            //Parse into the right format.
            command = CommandParser.ParseToGenerateCommand(nameOfMaze,
                                                           numOfRows,
                                                           numOfCols);

            CommandPropertyChanged = "generate";

            //Send command to the server.
            communicationClient.SendToServer(command);

            HandleServerResult(ServerResponse);
            //string generateResult;

            /* communicationClient.ServerListener.PropertyChanged +=
             *   delegate(Object sender, PropertyChangedEventArgs e)
             *   {
             *       //TODO the xaml gives only rows and name, columns missing
             *       generateResult = communicationClient.ServerListener.Command;
             *
             *       maze = Maze.FromJSON(generateResult);
             *   };*/
        }
        /// <summary>
        /// Requests the game list.
        /// </summary>
        public void RequestList()
        {
            string command;

            //Parse into the right format.
            command = CommandParser.ParseToListCommand();

            CommandPropertyChanged = "list";

            //Send command to the server.
            try
            {
                CommunicationClient.SendToServer(command);

                while (string.IsNullOrEmpty(ServerResponse))
                {
                    continue;
                }

                HandleServerResult(ServerResponse);
            }
            catch (ArgumentNullException)
            {
                this.ConnectionLost?.Invoke(this, null);
            }
        }
        /// <summary>
        /// Joins the game.
        /// </summary>
        /// <param name="gameName">Game name.</param>
        public void JoinGame(string gameName)
        {
            string command;

            //Parse into the right format.
            command = CommandParser.ParseToJoinCommand(gameName);

            IsSingleCommand = true;

            //Send command to the server.
            try
            {
                CommunicationClient.SendToServer(command);

                while (string.IsNullOrEmpty(ServerResponse))
                {
                    continue;
                }

                HandleMazeCommand(ServerResponse);
            }
            catch (ArgumentNullException)
            {
                this.ConnectionLost?.Invoke(this, null);
            }
        }
        /// <summary>
        /// Solves the game.
        /// </summary>
        /// <param name="name">Game name.</param>
        public void SolveMaze(string name)
        {
            new Task(() =>
            {
                //Disable controls.
                EnableControlsStatus = false;

                try
                {
                    string command;

                    //Set algorithm type.
                    string algorithmType = settingsModel.DefaultAlgo.ToString();

                    //Parse to solve command.
                    command =
                        CommandParser.ParseTOSolveCommand(name, algorithmType);

                    communicationClient.SendToServer(command);

                    solution = Reverse(
                        FromJsonConverter.MazeSolution(ServerResponse));

                    PlayerPosition = maze.InitialPos;

                    //Move according to directions.
                    foreach (char direction in solution)
                    {
                        switch (direction)
                        {
                        case '0':
                            PlayerPosition =
                                PerformMove(
                                    PlayerPosition, "right");
                            break;

                        case '1':
                            PlayerPosition =
                                PerformMove(
                                    PlayerPosition, "left");
                            break;

                        case '2':
                            PlayerPosition =
                                PerformMove(
                                    PlayerPosition, "up");
                            break;

                        case '3':
                            PlayerPosition =
                                PerformMove(
                                    PlayerPosition, "down");
                            break;
                        }

                        //Sleep between each move.
                        Thread.Sleep(250);
                    }
                }
                catch (ArgumentNullException)
                {
                    this.ConnectionLost?.Invoke(this, null);
                }

                //Enable controls.
                EnableControlsStatus = true;
            }).Start();
        }