You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.9 KiB
C#
69 lines
2.9 KiB
C#
1 week ago
|
#if !DISABLE_PLAYFABENTITY_API
|
||
|
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using PlayFab.LocalizationModels;
|
||
|
using PlayFab.Internal;
|
||
|
using PlayFab.SharedModels;
|
||
|
|
||
|
namespace PlayFab
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// The Localization APIs give you the tools needed to manage language setup in your title.
|
||
|
/// </summary>
|
||
|
public class PlayFabLocalizationInstanceAPI : IPlayFabInstanceApi
|
||
|
{
|
||
|
public readonly PlayFabApiSettings apiSettings = null;
|
||
|
public readonly PlayFabAuthenticationContext authenticationContext = null;
|
||
|
|
||
|
public PlayFabLocalizationInstanceAPI(PlayFabAuthenticationContext context)
|
||
|
{
|
||
|
if (context == null)
|
||
|
throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or call <PlayFabClientInstanceAPI>.GetAuthenticationContext()");
|
||
|
authenticationContext = context;
|
||
|
}
|
||
|
|
||
|
public PlayFabLocalizationInstanceAPI(PlayFabApiSettings settings, PlayFabAuthenticationContext context)
|
||
|
{
|
||
|
if (context == null)
|
||
|
throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or call <PlayFabClientInstanceAPI>.GetAuthenticationContext()");
|
||
|
apiSettings = settings;
|
||
|
authenticationContext = context;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Verify entity login.
|
||
|
/// </summary>
|
||
|
public bool IsEntityLoggedIn()
|
||
|
{
|
||
|
return authenticationContext == null ? false : authenticationContext.IsEntityLoggedIn();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Clear the Client SessionToken which allows this Client to call API calls requiring login.
|
||
|
/// A new/fresh login will be required after calling this.
|
||
|
/// </summary>
|
||
|
public void ForgetAllCredentials()
|
||
|
{
|
||
|
if (authenticationContext != null)
|
||
|
{
|
||
|
authenticationContext.ForgetAllCredentials();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Retrieves the list of allowed languages, only accessible by title entities
|
||
|
/// </summary>
|
||
|
public void GetLanguageList(GetLanguageListRequest request, Action<GetLanguageListResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Locale/GetLanguageList", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|