/// <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 Dictionary <string, string> PayVaultPaymentInfo(string provider, Dictionary <string, string> purchaseArguments, List <PayVaultBuyItemInfo> items) { var(success, response, error) = this.Channel.Request <PayVaultPaymentInfoArgs, PayVaultPaymentInfoOutput>(181, new PayVaultPaymentInfoArgs { Provider = provider, PurchaseArguments = DictionaryEx.Convert(purchaseArguments).ToList(), Items = items }); if (!success) { throw new PlayerIOError(error.ErrorCode, error.Message); } return(DictionaryEx.Convert(response.ProviderArguments)); }
public static (string joinKey, ServerEndPoint[] endpoints) JoinRoom(Client client, string roomId, Dictionary <string, string> joinData = null) { var(success, response, error) = client.Channel.Request <JoinRoomArgs, JoinRoomOutput>(24, new JoinRoomArgs { RoomId = roomId, JoinData = DictionaryEx.Convert(joinData), IsDevRoom = client.Multiplayer.DevelopmentServer != null }); if (!success) { throw new PlayerIOError(error.ErrorCode, error.Message); } return(response.JoinKey, response.Endpoints); }
internal PlayerInsight(PlayerInsightState state) { this.PlayersOnline = state.PlayersOnline; this.Segments = DictionaryEx.Convert(state.Segments); }