public void AuthenticateUser(string userName, string password, GameSparksController.RegCallback regcallback, GameSparksController.AuthCallback authcallback, GameSparksController.ErrorCallback errorCallback) { new GameSparks.Api.Requests.RegistrationRequest() // this login method first attempts a registration // // if the player is not new, we will be able to tell as the registrationResponse has a bool 'NewPlayer' which we can check // for this example we use the user-name was the display name also // .SetDisplayName(userName) .SetUserName(userName) .SetPassword(password) .Send((regResp) => { if (!regResp.HasErrors) { // if we get the response back with no errors then the registration was successful DebugTool.Instance().SetMessage(new DebugMessage("GSM| Registration Successful...", DebugMessageType.Message)); regcallback(regResp); } else { // if we receive errors in the response, then the first thing we check is if the player is new or not if (!(bool)regResp.NewPlayer) // player already registered, lets authenticate instead { DebugTool.Instance().SetMessage(new DebugMessage("GSM| Existing User, Switching to Authentication", DebugMessageType.Message)); new GameSparks.Api.Requests.AuthenticationRequest() .SetUserName(userName) .SetPassword(password) .Send((authResp) => { if (!authResp.HasErrors) { DebugTool.Instance().SetMessage(new DebugMessage("Authentication Successful...", DebugMessageType.Message)); authcallback(authResp); } else { DebugTool.Instance().SetMessage(new DebugMessage("GSM| Error Authenticating User \n", DebugMessageType.Error)); } }); } else { // if there is another error, then the registration must have failed DebugTool.Instance().SetMessage(new DebugMessage("GSM| Error Authenticating User \n", DebugMessageType.Error)); errorCallback(); } } }); }
/*------------------------------------------------------------------------------------------------------------------------------------------------------ * -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ public void AuthenticateUser(string userName, string password, GameSparksController.RegCallback regcallback, GameSparksController.AuthCallback authcallback, GameSparksController.ErrorCallback errorCallback) { }