Esempio n. 1
0
        public async override Task <RegisterRes> Register(RegisterReq request, ServerCallContext context)
        {
            GSUser user = mapper.Map <GSUser>(request);

            user.NickName  = user.Name;
            user.LoginTime = user.CreateTime = DateTime.Now;
            user.LoginPwd  = Md5Help.Md5Hash(user.LoginPwd + configuration["PwdHashSuffix"]);

            var key = await queryContext.AddAndGetKeyAsync(user);

            return(new RegisterRes()
            {
                ID = key, IsSuccess = true
            });
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            // If there is a user, update the display. Otherwise fetch the user info
            if (User != null)
            {
                UpdateUserInfo();
            }
            else
            {
                var request = GSRequest.Create("socialize.getUserInfo");

                // GSUser inherits from GSResponse. socialize.getUserInfo will always return GSUser if completed successfully
                User = (GSUser)await request.SendAsync();

                UpdateUserInfo();
            }
        }
 public virtual void UserInfoDidChange(GSUser user)
 {
     User = user;
     UpdateUserInfo();
 }
Esempio n. 4
0
 void UserInfoHandler(GSUser arg0, NSError arg1)
 {
     UnitTestAppDelegate.User = arg0;
 }
Esempio n. 5
0
 void UserInfoHandler(GSUser arg0, NSError arg1)
 {
     UnitTestAppDelegate.User = arg0;
 }
Esempio n. 6
0
    /// <summary>
    /// Sends an authentication request or registration request to GS.
    /// </summary>
    /// <param name="_callback1">Auth-Response</param>
    /// <param name="_callback2">Registration-Response</param>
    public void AuthenticateUser(string _userName, string _password, RegCallback _regcallback, AuthCallback _authcallback)
    {
        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
                Debug.Log("GSM| Registration Successful...");

                user = new GSUser
                {
                    userId      = regResp.UserId,
                    displayName = regResp.DisplayName
                };

                _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
                {
                    Debug.LogWarning("GSM| Existing User, Switching to Authentication");
                    new GameSparks.Api.Requests.AuthenticationRequest()
                    .SetUserName(_userName)
                    .SetPassword(_password)
                    .Send((authResp) =>
                    {
                        if (!authResp.HasErrors)
                        {
                            Debug.Log("Authentication Successful...");

                            user = new GSUser
                            {
                                userId      = authResp.UserId,
                                displayName = authResp.DisplayName
                            };

                            _authcallback(authResp);
                        }
                        else
                        {
                            Debug.LogWarning("GSM| Error Authenticating User \n" + authResp.Errors.JSON);
                        }
                    });
                }
                else
                {
                    // if there is another error, then the registration must have failed
                    Debug.LogWarning("GSM| Error Authenticating User \n" + regResp.Errors.JSON);
                }
            }
        });
    }