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; } }