/// <summary>Connects to Player.IO using as the given user</summary> /// <param name="gameId">The game id of the game you wish to connect to. This value can be found in the admin panel</param> /// <param name="connectionId">The id of the connection, as given in the settings section of the admin panel. 'public' should be used as the default</param> /// <param name="authenticationArguments">A dictionary of arguments for the given connection.</param> /// <param name="playerInsightSegments">Custom segments for the user in PlayerInsight.</param> public static Client Authenticate(string gameId, string connectionId, Dictionary <string, string> authenticationArguments = null, string[] playerInsightSegments = null) { if (authenticationArguments?.ContainsKey("secureSimpleUserPasswordsOverHttp") == true && authenticationArguments["secureSimpleUserPasswordsOverHttp"] == "true") { var identifier = SimpleUserGetSecureLoginInfo(); authenticationArguments["password"] = PlayerIO.SimpleUserPasswordEncrypt(identifier.PublicKey, authenticationArguments["password"]); authenticationArguments["nonce"] = identifier.Nonce; } var identifier2 = Authenticate(gameId, connectionId, authenticationArguments ?? null, playerInsightSegments?.ToList() ?? null, PlayerIO.GetClientAPI(), PlayerIO.GetClientInfo(), PlayerIO.GetPlayCodes()); PlayerIO.ServerApiEndpoints = identifier2.ApiServerHosts; PlayerIO.ServerApiSecurity = identifier2.ApiSecurity; // TODO: Don't want to overwrite any custom user-set end-point... PlayerIO.SetAPIEndpoint(PlayerIO.ServerApiEndpoints[0]); return(new Client(Channel, gameId, identifier2.GameFSRedirectMap, identifier2.Token, identifier2.UserId, identifier2.ShowBranding, identifier2.IsSocialNetworkUser, null)); }
internal bool SimpleChangeEmail(string gameId, string connectionId, string connectionType, string currentUsernameOrEmail, string currentPassword, string newEmail, out string requestResponse) { var requestFinished = false; var changeSuccessful = false; var playerIOError = default(PlayerIOError); _channel.Request <AuthenticateArgs, NoArgsOrOutput, PlayerIOError>(13, new AuthenticateArgs { GameId = gameId, ClientAPI = PlayerIO.GetClientAPI(), ConnectionId = connectionId, AuthenticationArguments = new KeyValuePair[] { new KeyValuePair() { Key = connectionType, Value = currentUsernameOrEmail }, new KeyValuePair() { Key = "password", Value = currentPassword }, new KeyValuePair() { Key = "changeemail", Value = "true" }, new KeyValuePair() { Key = "newemail", Value = newEmail } } }, new Callback <PlayerIOError>((error) => { if (error.ErrorCode == ErrorCode.GeneralError && error.Message.ToLower().Contains("email address changed")) { changeSuccessful = true; } playerIOError = error; requestFinished = true; })); // this is really sloppy and could be improved, but it's quick and easy... // and the same description would generally apply to Player.IO as a whole :wink: // - atillabyte requestResponse = playerIOError?.Message ?? ""; var requestTimeout = 0; while (!requestFinished && ++requestTimeout <= 10000 / 100) { Thread.Sleep(100); } if (!requestFinished) { throw new Exception("The email change request timed out without returning a response."); } if (requestFinished && changeSuccessful) { return(true); } return(false); }