/// <summary> /// 회원가입 /// </summary> public void Register() { var request = new PlayFab.ClientModels.RegisterPlayFabUserRequest { Email = email, Password = password, Username = userName, DisplayName = nickName }; PlayFabClientAPI.RegisterPlayFabUser(request, OnRegisterSuccess, OnRegistFail); }
void register (){ if (password_text.text == confirm_password_text.text){ RegisterPlayFabUserRequest request = new RegisterPlayFabUserRequest(); request.Username = username_text.text; request.Password = password_text.text; request.Email = email_text.text; request.TitleId = PlayFabData.TitleId; PlayFabClientAPI.RegisterPlayFabUser(request,register_successful,register_failed); } }
public void Register() { var request = new RegisterPlayFabUserRequest() { TitleId = PlayFabSettings.TitleId, Username = RegUsernameField.text, Password = RegPasswordField.text, Email = RegEmailField.text }; PlayFabClientAPI.RegisterPlayFabUser(request, (result) => { LoginRegisterSuccess(result.PlayFabId,result.SessionTicket); }, (error) => { RegErrorText.text = error.ErrorMessage; RegErrorText.gameObject.transform.parent.gameObject.SetActive(true); PlayFabErrorHandler.HandlePlayFabError(error); }); }
//Create an account onPlayFab public static void PlayFabRegister(string username, string password, string email) { var registerRequest = new RegisterPlayFabUserRequest() { TitleId = PlayFabSettings.TitleId, Username = username, Password = password, Email = email }; PlayFabClientAPI.RegisterPlayFabUser(registerRequest, (result) => { PlayFabDataStore.playFabId = result.PlayFabId; PlayFabDataStore.sessionTicket = result.SessionTicket; GetPhotonToken(); }, (error) => { PlayFabUserLogin.playfabUserLogin.Authentication(error.ErrorMessage.ToString().ToUpper(), 3); }); }
public void TestCallbackFailures() { PlayFabSettings.HideCallbackErrors = true; // Just need any valid auth token for this test LoginWithCustomIDRequest loginRequest = new LoginWithCustomIDRequest(); loginRequest.CreateAccount = true; loginRequest.CustomId = SystemInfo.deviceUniqueIdentifier; PlayFabClientAPI.LoginWithCustomID(loginRequest, null, null); WaitForApiCalls(); PlayFabSettings.RegisterForResponses(null, (PlayFabSettings.ResponseCallback<object, PlayFabResultCommon>)SuccessCallback_Global); PlayFabSettings.GlobalErrorHandler += SharedError_Global; callbacks.Clear(); GetCatalogItemsRequest catalogRequest = new GetCatalogItemsRequest(); PlayFabClientAPI.GetCatalogItems(catalogRequest, GetCatalogItemsCallback_Single, SharedError_Single); WaitForApiCalls(); UUnitAssert.True(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // All success callbacks should occur, even if some throw exceptions UUnitAssert.True(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global"); // All success callbacks should occur, even if some throw exceptions UUnitAssert.False(callbacks.Contains("SharedError_Single"), "SharedError_Single"); // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions) UUnitAssert.False(callbacks.Contains("SharedError_Global"), "SharedError_Global"); // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions) UUnitAssert.IntEquals(2, callbacks.Count); callbacks.Clear(); RegisterPlayFabUserRequest registerRequest = new RegisterPlayFabUserRequest(); PlayFabClientAPI.RegisterPlayFabUser(registerRequest, RegisterPlayFabUserCallback_Single, SharedError_Single); WaitForApiCalls(); UUnitAssert.False(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // Success should not have occurred UUnitAssert.False(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global"); // Success should not have occurred UUnitAssert.True(callbacks.Contains("SharedError_Single"), "SharedError_Single"); // All error callbacks should occur, even if some throw exceptions UUnitAssert.True(callbacks.Contains("SharedError_Global"), "SharedError_Global"); // All error callbacks should occur, even if some throw exceptions UUnitAssert.IntEquals(2, callbacks.Count); callbacks.Clear(); PlayFabSettings.HideCallbackErrors = false; PlayFabSettings.ForceUnregisterAll(); }
public void LoginOrRegister() { if (!PlayFabClientAPI.IsClientLoggedIn()) // If we haven't already logged in... { var loginRequest = new ClientModels.LoginWithEmailAddressRequest(); loginRequest.Email = USER_EMAIL; loginRequest.Password = USER_PASSWORD; loginRequest.TitleId = PlayFabSettings.TitleId; var loginTask = PlayFabClientAPI.LoginWithEmailAddressAsync(loginRequest); loginTask.Wait(); if (loginTask.Result != null && loginTask.Result.Result != null) // If successful, track playFabId playFabId = loginTask.Result.Result.PlayFabId; // Needed for subsequent tests } if (PlayFabClientAPI.IsClientLoggedIn()) return; // Success, already logged in // If the setup failed to log in a user, we need to create one. var registerRequest = new ClientModels.RegisterPlayFabUserRequest(); registerRequest.TitleId = PlayFabSettings.TitleId; registerRequest.Username = USER_NAME; registerRequest.Email = USER_EMAIL; registerRequest.Password = USER_PASSWORD; var registerTask = PlayFabClientAPI.RegisterPlayFabUserAsync(registerRequest); registerTask.Wait(); UUnitAssert.NotNull(registerTask.Result); UUnitAssert.Null(registerTask.Result.Error); UUnitAssert.NotNull(registerTask.Result.Result); playFabId = registerTask.Result.Result.PlayFabId; // Needed for subsequent tests UUnitAssert.True(PlayFabClientAPI.IsClientLoggedIn(), "User login failed"); }
/// <summary> /// Registers a new Playfab user account, returning a session identifier that can subsequently be used for API calls which require an authenticated user. You must supply either a username or an email address. /// </summary> public static void RegisterPlayFabUser(RegisterPlayFabUserRequest request, ProcessApiCallback<RegisterPlayFabUserResult> resultCallback, ErrorCallback errorCallback, object customData = null) { request.TitleId = request.TitleId ?? PlayFabSettings.TitleId; if (request.TitleId == null) throw new Exception("Must be have PlayFabSettings.TitleId set to call this method"); string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy); Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer) { ResultContainer<RegisterPlayFabUserResult>.HandleResults(requestContainer, resultCallback, errorCallback, RegisterPlayFabUserResultAction); }; PlayFabHTTP.Post("/Client/RegisterPlayFabUser", serializedJson, null, null, callback, request, customData); }
void OnGUI() { if (PlayFabGameBridge.gameState == 1) { Time.timeScale = 0.0f; // pause everything while we show the UI Rect winRect = new Rect (0,0,playfabBackground.width, playfabBackground.height); winRect.x = (int) ( Screen.width * 0.5f - winRect.width * 0.5f ); winRect.y = (int) ( Screen.height * 0.5f - winRect.height * 0.5f ); yStart = winRect.y + 80; GUI.DrawTexture (winRect, playfabBackground); if (!isEmail) { errorLabel = "Invalid email address"; } else if (!isPassword) { errorLabel = "Passwords do not match"; } else if (!returnedError) { errorLabel = ""; } GUI.Label (new Rect (winRect.x + 18, yStart -16, 120, 30), "<size=18>"+title+"</size>"); GUI.Label (new Rect (winRect.x + 18, yStart +25, 120, 20), userNameLabel); GUI.Label (new Rect (winRect.x +18, yStart +50, 120, 20), emailLabel); GUI.Label (new Rect (winRect.x +18, yStart +75, 120, 20), passwordLabel); GUI.Label (new Rect (winRect.x +18, yStart +100, 120, 20), confirmPasswordLabel); GUI.Label (new Rect (winRect.x +18, yStart +200, 120, 20), "OR"); userNameField = GUI.TextField (new Rect (winRect.x +135, yStart+25, 100, 20), userNameField); emailField = GUI.TextField (new Rect (winRect.x +135, yStart +50, 100, 20), emailField); passwordField = GUI.PasswordField (new Rect (winRect.x +135, yStart +75, 100, 20), passwordField,"*"[0], 20); confirmPasswordField = GUI.PasswordField (new Rect (winRect.x +135, yStart+100, 100, 20), confirmPasswordField,"*"[0], 20); GUI.Label (new Rect (winRect.x +18, yStart +128, 200, 20), errorLabel, errorStyle); if(confirmPasswordField.Length>0) validatePassword (); if (GUI.Button (new Rect (winRect.x +18, yStart+155, 100, 30), "Register")||Event.current.Equals(Event.KeyboardEvent("[enter]"))) { validateEmail(); validatePassword(); if(isEmail && isPassword) { returnedError = false; RegisterPlayFabUserRequest request = new RegisterPlayFabUserRequest(); request.TitleId = PlayFabData.TitleId; request.Username = userNameField; request.Email = emailField; request.Password = passwordField; Debug.Log("TitleId : "+request.TitleId); PlayFabClientAPI.RegisterPlayFabUser(request,OnRegisterResult,OnPlayFabError); } } if (GUI.Button(new Rect(winRect.x +18,yStart +235, 80, 20),"Log In")) { PlayFabGameBridge.gameState = 2; } if (Input.mousePosition.x < winRect.x + winRect.width && Input.mousePosition.x > winRect.x && Screen.height - Input.mousePosition.y < winRect.y + winRect.height && Screen.height - Input.mousePosition.y > winRect.y){ Rect cursorRect = new Rect (Input.mousePosition.x,Screen.height-Input.mousePosition.y,cursor.width,cursor.height ); GUI.DrawTexture (cursorRect, cursor); } } }
public void LoginOrRegister() { if (!PlayFabClientAPI.IsClientLoggedIn()) // If we haven't already logged in... { var loginRequest = new LoginWithEmailAddressRequest(); loginRequest.Email = USER_EMAIL; loginRequest.Password = USER_PASSWORD; loginRequest.TitleId = PlayFabSettings.TitleId; PlayFabClientAPI.LoginWithEmailAddress(loginRequest, LoginCallback, SharedErrorCallback); WaitForApiCalls(); // We don't do any test here, because the user may not exist, and thus login might fail, but the test should not } if (PlayFabClientAPI.IsClientLoggedIn()) return; // Success, already logged in // If the setup failed to log in a user, we need to create one. var registerRequest = new RegisterPlayFabUserRequest(); registerRequest.TitleId = PlayFabSettings.TitleId; registerRequest.Username = USER_NAME; registerRequest.Email = USER_EMAIL; registerRequest.Password = USER_PASSWORD; PlayFabClientAPI.RegisterPlayFabUser(registerRequest, RegisterCallback, SharedErrorCallback); WaitForApiCalls(); UUnitAssert.StringEquals("User Registration Successful", lastReceivedMessage); // If we get here, we definitely registered a new user, and we definitely want to verify success UUnitAssert.True(PlayFabClientAPI.IsClientLoggedIn(), "User login failed"); }
public void InvalidRegistration() { var registerRequest = new RegisterPlayFabUserRequest(); registerRequest.TitleId = PlayFabSettings.TitleId; registerRequest.Username = "******"; // Provide invalid inputs for multiple parameters, which will show up in errorDetails registerRequest.Email = "x"; // Provide invalid inputs for multiple parameters, which will show up in errorDetails registerRequest.Password = "******"; // Provide invalid inputs for multiple parameters, which will show up in errorDetails PlayFabClientAPI.RegisterPlayFabUser(registerRequest, RegisterCallback, SharedErrorCallback); WaitForApiCalls(); var expectedEmailMsg = "email address is not valid."; var expectedPasswordMsg = "password must be between"; UUnitAssert.True(lastReceivedMessage.ToLower().Contains(expectedEmailMsg), lastReceivedMessage); UUnitAssert.True(lastReceivedMessage.ToLower().Contains(expectedPasswordMsg), lastReceivedMessage); }
/// <summary> /// Function to be called when the user will create a new account from scratch. /// </summary> /// <param name="username">User's chosen username</param> /// <param name="password">User's chosen password</param> /// <param name="email">User's chosen email</param> /// <param name="OnUserCreatedCallback">Function to call after process ends.</param> public void CreateNewUser(string username, string password, string email, ProjectDelegates.PlayFabLoginCallback OnUserCreatedCallback) { this.OnLoginCompletedCallback = OnUserCreatedCallback; PlayFabSettings.TitleId = playFabGameID; RegisterPlayFabUserRequest request = new RegisterPlayFabUserRequest(); request.Username = username; request.Password = password; request.Email = email; request.TitleId = playFabGameID; PlayFabClientAPI.RegisterPlayFabUser(request, OnRegistrationCompleted, OnLoginError); }
/// <summary> /// Registers a new Playfab user account, returning a session identifier that can subsequently be used for API calls which require an authenticated user. You must supply either a username or an email address. /// </summary> public static async Task<PlayFabResult<RegisterPlayFabUserResult>> RegisterPlayFabUserAsync(RegisterPlayFabUserRequest request) { request.TitleId = PlayFabSettings.TitleId ?? request.TitleId; if(request.TitleId == null) throw new Exception ("Must be have PlayFabSettings.TitleId set to call this method"); object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/RegisterPlayFabUser", request, null, null); if(httpResult is PlayFabError) { PlayFabError error = (PlayFabError)httpResult; if (PlayFabSettings.GlobalErrorHandler != null) PlayFabSettings.GlobalErrorHandler(error); return new PlayFabResult<RegisterPlayFabUserResult> { Error = error, }; } string resultRawJson = (string)httpResult; var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); var resultData = serializer.Deserialize<PlayFabJsonSuccess<RegisterPlayFabUserResult>>(new JsonTextReader(new StringReader(resultRawJson))); RegisterPlayFabUserResult result = resultData.data; AuthKey = result.SessionTicket ?? AuthKey; return new PlayFabResult<RegisterPlayFabUserResult> { Result = result }; }
public IEnumerator makeRegister() { RegisterPlayFabUserRequest request = new RegisterPlayFabUserRequest() { TitleId = PlayFabSettings.TitleId, Username = username, Email = email, Password = password, RequireBothUsernameAndEmail = true }; wait = true; PlayFabClientAPI.RegisterPlayFabUser(request, (result) => { registerSuccesfull(result); wait = false; }, (error) => { registerFail(error); wait = false; }); while (wait) { yield return null; } }
public void TestCallbackFailuresLocal(UUnitTestContext testContext) { PlayFabSettings.HideCallbackErrors = true; PlayFabSettings.GlobalErrorHandler += SharedError_Global; RegisterPlayFabUserRequest registerRequest = new RegisterPlayFabUserRequest(); // A bad request that will fail PlayFabClientAPI.RegisterPlayFabUser(registerRequest, null, PlayFabUUnitUtils.ApiErrorWrapper(testContext, SharedError_Single), testContext); }
/// <summary> /// Sends a request to make a new Playfab account. /// </summary> /// <param name="username">The username of the account that is being created.</param> /// <param name="email">E-mail for the new account.</param> /// <param name="password">The password of the account that is being created.</param> public void RegisterWithPlayfab(string username, string email, string password) { RegisterPlayFabUserRequest request = new RegisterPlayFabUserRequest(); request.TitleId = PlayFabData.TitleId; request.Username = username; request.Email = email; request.Password = password; Debug.Log("TitleId : " + request.TitleId); PlayFabClientAPI.RegisterPlayFabUser(request, OnRegisterResult, OnPlayFabError); }
/// <summary> /// Registers a new Playfab user account, returning a session identifier that can subsequently be used for API calls which require an authenticated user /// </summary> public static void RegisterPlayFabUser(RegisterPlayFabUserRequest request, RegisterPlayFabUserCallback resultCallback, ErrorCallback errorCallback) { request.TitleId = PlayFabSettings.TitleId ?? request.TitleId; if(request.TitleId == null) throw new Exception ("Must be have PlayFabSettings.TitleId set to call this method"); string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings); Action<string,string> callback = delegate(string responseStr, string errorStr) { RegisterPlayFabUserResult result = null; PlayFabError error = null; ResultContainer<RegisterPlayFabUserResult>.HandleResults(responseStr, errorStr, out result, out error); if(error != null && errorCallback != null) { errorCallback(error); } if(result != null) { AuthKey = result.SessionTicket ?? AuthKey; if(resultCallback != null) { resultCallback(result); } } }; PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/RegisterPlayFabUser", serializedJSON, null, null, callback); }
public void InvalidRegistration(UUnitTestContext testContext) { var registerRequest = new RegisterPlayFabUserRequest(); registerRequest.TitleId = PlayFabSettings.TitleId; registerRequest.Username = "******"; // Provide invalid inputs for multiple parameters, which will show up in errorDetails registerRequest.Email = "x"; // Provide invalid inputs for multiple parameters, which will show up in errorDetails registerRequest.Password = "******"; // Provide invalid inputs for multiple parameters, which will show up in errorDetails PlayFabClientAPI.RegisterPlayFabUser(registerRequest, PlayFabUUnitUtils.ApiCallbackWrapper<RegisterPlayFabUserResult>(testContext, InvalidRegistrationCallback), PlayFabUUnitUtils.ApiErrorWrapper(testContext, ExpectedRegisterErrorCallback), testContext); }
private void OnGUI () { GUI.Label (ResizeGUI(new Rect (10, 10, 500, 30)), PhotonNetwork.connectionStateDetailed.ToString ()); if (!PhotonNetwork.connected) networkState = NetworkStates.NotLoggedIn; else if (PhotonNetwork.room == null) networkState = NetworkStates.InLobby; else if (PhotonNetwork.room != null) networkState = NetworkStates.InRoom; else networkState = NetworkStates.Unknown; // Network state machine switch (networkState) { case NetworkStates.NotLoggedIn: { /* if (GUI.Button (new Rect (10, 10, 150, 70), "Login to Facebook")) { FB.Login ("email", LoginCallback); } */ if (hasError) { StartCoroutine("waitForError"); GUIStyle myStyle = new GUIStyle (); myStyle.fontSize = 36; GUI.Label (ResizeGUI(new Rect (10, 50, 200, 20)), myErrorMessage, myStyle); } username = GUI.TextField (ResizeGUI(new Rect (10, 100, 200, 20)), username); email = GUI.TextField (ResizeGUI(new Rect (10, 130, 200, 20)), email); password = GUI.PasswordField (ResizeGUI(new Rect (10, 160, 200, 20)), password, '*'); if (GUI.Button (ResizeGUI(new Rect (10, 210, 150, 30)), "Create Account")) { audioManager.playClick(); RegisterPlayFabUserRequest request = new RegisterPlayFabUserRequest (); request.TitleId = PlayFabSettings.TitleId; request.Username = username; request.Email = email; request.Password = password; PlayFabClientAPI.RegisterPlayFabUser (request, OnPlayFabRegisterSuccess, OnPlayFabError); } if (GUI.Button (ResizeGUI(new Rect (10, 250, 150, 30)), "Login with Username")) { audioManager.playClick(); LoginWithPlayFabRequest request = new LoginWithPlayFabRequest (); request.Username = username; request.Password = password; request.TitleId = PlayFabData.TitleId; PlayFabClientAPI.LoginWithPlayFab (request, OnPlayFabLoginSuccess, OnPlayFabError); } if (GUI.Button (ResizeGUI(new Rect (10, 290, 150, 30)), "Login with Email")) { audioManager.playClick(); LoginWithEmailAddressRequest request = new LoginWithEmailAddressRequest(); request.Email = email; request.Password = password; request.TitleId = PlayFabData.TitleId; PlayFabClientAPI.LoginWithEmailAddress(request, OnPlayFabLoginSuccess, OnPlayFabError); } break; } case NetworkStates.InLobby: { if (joinedRoom) { GameObject board = GameObject.Find("Board"); Destroy(board); audioManager.source.Stop(); audioManager.loopMenuMusic(); background.SetActive(true); title.SetActive(true); turnManager.currentPlayer = 0; // resets game when you leave turnManager.gameOver = false; turnManager.gameStarted = false; turnManager.movesPerTurn = 2; GameObject go = GameObject.FindGameObjectWithTag ("Canvas"); ActionMenu actionMenu = (ActionMenu)go.transform.FindChild ("ActionMenu(Clone)").GetComponent<ActionMenu>(); actionMenu.DestroyActionMenu(); joinedRoom = false; } inRoom = false; createRoomName = GUI.TextField (ResizeGUI(new Rect (10, 110, 150, 30)), createRoomName); // Create game button if (GUI.Button (ResizeGUI(new Rect (10, 50, 150, 50)), "Create Game")) { audioManager.playClick(); Debug.Log ("room name = " + createRoomName); PhotonNetwork.CreateRoom (createRoomName, true, true, 5); } // Join existing game button if (roomsList != null) { for (int i = 0; i < roomsList.Length; i++) { if (GUI.Button (ResizeGUI(new Rect (10, 180 + (80 * i), 150, 70)), "Join " + roomsList [i].name)) { audioManager.playClick(); PhotonNetwork.JoinRoom (roomsList [i].name); } } } break; } case NetworkStates.InRoom: // in room so instantiate player { inRoom = true; GUILayout.Label ("Your name: " + PhotonNetwork.playerName + " - " + playfabUserID ); GUILayout.Label (PhotonNetwork.playerList.Length + " players in this room."); GUILayout.Label ("The others are:"); foreach (PhotonPlayer player in PhotonNetwork.otherPlayers) { GUILayout.Label (player.ToString ()); } if (GUI.Button (ResizeGUI(new Rect (10, 70, 150, 30)), "Leave")) { audioManager.playClick(); PhotonNetwork.LeaveRoom (); } break; } case NetworkStates.Unknown: { GUILayout.Label ("Unknown network state!"); break; } } if (PhotonNetwork.connected && !inRoom) { if (GUI.Button (ResizeGUI(new Rect (10, Screen.height - 70, 150, 30)), "Logout")) { audioManager.playClick(); if (FB.IsLoggedIn) FB.Logout (); PhotonNetwork.Disconnect (); } } }