private void CheckPlayerCanRegister(RegisterClientLogin _objectMessage)
        {
            if (_objectMessage.stateConnectionMode == StateConnectionMode.REGISTER)
            {
                if (CheckUsernameExist(_objectMessage.username) == false)
                {
                    Debug.Log("Username Exist");

                    tmpDataBufferPlayerRegister = new ClientData(_objectMessage.username, _objectMessage.password, data.CountIDUnique);

                    stateConnectionBuffer  = StateConnectionMessage.REGISTER_SUCCESSFUL;
                    sendStateLoginRegister = true;

                    if (SaveSystem.RegisterPlayer(tmpDataBufferPlayerRegister, data) == true)
                    {
                        Debug.Log("Password Is Set : " + _objectMessage.password);
                        stateConnectionBuffer  = StateConnectionMessage.REGISTER_SUCCESSFUL;
                        sendStateLoginRegister = true;
                    }
                    else
                    {
                        Debug.Log("Password Is Not Set : " + _objectMessage.password);
                    }
                }
                else
                {
                    Debug.Log("Username Is Not Available.");
                    //Send a message to a client
                    sendStateLoginRegister = true;
                    stateConnectionBuffer  = StateConnectionMessage.REGISTER_USERNAME_NON_AVAILABLE;
                }
            }
        }
        private void CheckPlayerCanLogin(RegisterClientLogin _objectMessage)
        {
            if (CheckUsernameExist(_objectMessage.username) == true)
            {
                Debug.Log("Username exist");
                if (CheckPasswordCorrespond(_objectMessage.username, _objectMessage.password) == true)
                {
                    if (CheckAccountIsAlreadyConnect(_objectMessage.username) == true)
                    {
                        Debug.Log("Password Correspond");

                        for (int i = 0; i < _playerList.Count; i++)
                        {
                            if (_playerList[i].connectionToClient == _connBuffer)
                            {
                                _playerList[i]._username = _objectMessage.username;
                            }
                        }

                        stateConnectionBuffer  = StateConnectionMessage.LOGIN_USERNAME_PASSWORD_CORRESPOND_AND_IS_NOT_CONNECTED;
                        sendStateLoginRegister = true;
                        Debug.Log("Username Before Set Data" + _objectMessage.username);
                        _usernameBuffer = formateToByte(_objectMessage.username);

                        //Load Data Login
                        LoadDataLoginClient(_connBuffer);
                    }
                    else
                    {
                        stateConnectionBuffer = StateConnectionMessage.ACCOUNT_ALREADY_CONNECT;
                    }
                }
                else
                {
                    sendStateLoginRegister = true;

                    Debug.Log("Password doesn't Correspond");
                    stateConnectionBuffer = StateConnectionMessage.LOGIN_USERNAME_PASSWORD_DOES_NOT_CORRESPOND;
                }
            }
            else
            {
                Debug.Log("Username doesn't exist");
                stateConnectionBuffer  = StateConnectionMessage.LOGIN_USERNAME_DOES_NOT_EXIST;
                sendStateLoginRegister = true;
            }
        }
        public void TreatRecvMessageByClient(NetworkMessage _msg)
        {
            //Read and stock the message send by the Client
            RegisterClientLogin objectMessage = _msg.ReadMessage <RegisterClientLogin>();

            _connBuffer = _msg.conn;

            Debug.Log("Object Message : " + objectMessage.username);

            CheckPlayerCanLogin(objectMessage);
            CheckPlayerCanRegister(objectMessage);

            if (objectMessage.stateConnectionMode != StateConnectionMode.LOGIN &&
                objectMessage.stateConnectionMode != StateConnectionMode.REGISTER)
            {
            }
        }
        public void RegisterHost(StateConnectionMode _stateConnectionMode)
        {
            if (_menuManager != null)
            {
                //Register a new Message who can be sent to the server
                RegisterClientLogin msg = new RegisterClientLogin();
                Debug.Log("test");
                msg.stateConnectionMode = _stateConnectionMode;
                string passwordBuffer;
                if (_stateConnectionMode == StateConnectionMode.LOGIN)
                {
                    msg.username   = _menuManager._userName.text;
                    passwordBuffer = _menuManager._password.text;
                }
                else if (_stateConnectionMode == StateConnectionMode.REGISTER)
                {
                    msg.username   = _menuManager._userNameInscrire.text;
                    passwordBuffer = _menuManager._passwordInscrire.text;
                }
                else
                {
                    msg.username   = _menuManager._userName.text;
                    passwordBuffer = _menuManager._password.text;
                }
                //Check if the username and the password are on a good format
                //if (CheckIsCorrectFormat(msg.username, passwordBuffer, 4, 12, 7, 16) == true)
                {
                    //Encryption of the password
                    msg.password = passwordBuffer.GetHashCode();

                    //Send Login of Client (Username and Password) to the Server.
                    if (client.Send(RegisterClientLoginMsgId, msg) == true)
                    {
                        Debug.Log("Message is Send");
                    }
                    else
                    {
                        Debug.LogWarning("Message isn't Send");
                    }
                }
            }
        }