/// <summary> /// Connect to Player.IO using as the given user. /// </summary> /// <param name="gameId"> The 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, string[] playerInsightSegments = null) { if (authenticationArguments?.ContainsKey("secureSimpleUserPasswordsOverHttp") == true && authenticationArguments["secureSimpleUserPasswordsOverHttp"] == "true") { var(publicKey, nonce) = PlayerIOAuth.SimpleUserGetSecureLoginInfo(); authenticationArguments["password"] = PlayerIOAuth.SimpleUserPasswordEncrypt(publicKey, authenticationArguments["password"]); authenticationArguments["nonce"] = nonce; } var(success, response, error) = new PlayerIOChannel().Request <AuthenticateArgs, AuthenticateOutput>(13, new AuthenticateArgs { GameId = gameId, ConnectionId = connectionId, AuthenticationArguments = DictionaryEx.Convert(authenticationArguments ?? new Dictionary <string, string>()), PlayerInsightSegments = playerInsightSegments?.ToList() ?? new List <string>(), ClientAPI = $"csharp", ClientInfo = DictionaryEx.Convert(PlayerIOAuth.GetClientInfo()), PlayCodes = new List <string>() }); if (!success) { throw new PlayerIOError(error.ErrorCode, error.Message); } return(new Client(new PlayerIOChannel() { Token = response.Token }) { PlayerInsight = new PlayerInsight(response.PlayerInsightState), ConnectUserId = response.UserId, }); }
internal Client(PlayerIOChannel channel) { this.Channel = channel; this.Token = channel.Token; this.Multiplayer = new Multiplayer(channel); this.BigDB = new BigDB(channel); this.ErrorLog = new ErrorLog(channel); this.PayVault = new PayVault(channel, this.ConnectUserId); }
internal Client(PlayerIOChannel channel, string gameId) { this.Channel = channel; this.GameId = gameId; this.Multiplayer = new Multiplayer(channel); this.BigDB = new BigDB(channel); this.ErrorLog = new ErrorLog(channel); this.PayVault = new PayVault(channel, this.ConnectUserId); }
internal static (byte[] publicKey, string nonce) SimpleUserGetSecureLoginInfo() { var(success, response, error) = new PlayerIOChannel().Request <EmptyOutput, SimpleUserGetSecureLoginInfoOutput>(424, new EmptyOutput()); if (!success) { throw new PlayerIOError(error.ErrorCode, error.Message); } return(response.PublicKey, response.Nonce); }
/// <summary> /// Create a captcha image and key from the specified game, to be used for registrations where the added security of captcha is required. /// </summary> /// <param name="width"> The width of the captcha image. </param> /// <param name="height"> The height of the captcha image. </param> public static SimpleCaptcha CreateCaptcha(string gameId, int width, int height) { if (string.IsNullOrEmpty(gameId)) { throw new ArgumentException("A game ID must be specified in order to use this method."); } var(success, response, error) = new PlayerIOChannel().Request <SimpleGetCaptchaArgs, SimpleGetCaptchaOutput>(415, new SimpleGetCaptchaArgs { GameId = gameId, Width = width, Height = height }); if (!success) { throw new PlayerIOError(error.ErrorCode, error.Message); } return(new SimpleCaptcha(response.CaptchaKey, response.CaptchaImageUrl)); }
internal ErrorLog(PlayerIOChannel channel) { this.Channel = channel; }
internal BigDB(PlayerIOChannel channel) { this.Channel = channel; }