#if ENABLE_PLAYFABSERVER_API
using System;
using System.Collections.Generic;
using PlayFab.MatchmakerModels;
using PlayFab.Internal;
using PlayFab.SharedModels;
namespace PlayFab
{
///
/// Enables the use of an external match-making service in conjunction with PlayFab hosted Game Server instances
///
public class PlayFabMatchmakerInstanceAPI : IPlayFabInstanceApi
{
public readonly PlayFabApiSettings apiSettings = null;
public readonly PlayFabAuthenticationContext authenticationContext = null;
public PlayFabMatchmakerInstanceAPI(PlayFabAuthenticationContext context)
{
if (context == null)
throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or call .GetAuthenticationContext()");
authenticationContext = context;
}
public PlayFabMatchmakerInstanceAPI(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 .GetAuthenticationContext()");
apiSettings = settings;
authenticationContext = context;
}
///
/// Clear the Client SessionToken which allows this Client to call API calls requiring login.
/// A new/fresh login will be required after calling this.
///
public void ForgetAllCredentials()
{
if (authenticationContext != null)
{
authenticationContext.ForgetAllCredentials();
}
}
///
/// Validates a user with the PlayFab service
///
[Obsolete("No longer available", true)]
public void AuthUser(AuthUserRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
if (string.IsNullOrEmpty(callSettings.DeveloperSecretKey)) { throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "Must set DeveloperSecretKey in settings to call this method"); }
PlayFabHttp.MakeApiCall("/Matchmaker/AuthUser", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
}
///
/// Informs the PlayFab game server hosting service that the indicated user has joined the Game Server Instance specified
///
[Obsolete("No longer available", true)]
public void PlayerJoined(PlayerJoinedRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
if (string.IsNullOrEmpty(callSettings.DeveloperSecretKey)) { throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "Must set DeveloperSecretKey in settings to call this method"); }
PlayFabHttp.MakeApiCall("/Matchmaker/PlayerJoined", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
}
///
/// Informs the PlayFab game server hosting service that the indicated user has left the Game Server Instance specified
///
[Obsolete("No longer available", true)]
public void PlayerLeft(PlayerLeftRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
if (string.IsNullOrEmpty(callSettings.DeveloperSecretKey)) { throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "Must set DeveloperSecretKey in settings to call this method"); }
PlayFabHttp.MakeApiCall("/Matchmaker/PlayerLeft", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
}
///
/// Retrieves the relevant details for a specified user, which the external match-making service can then use to compute
/// effective matches
///
[Obsolete("No longer available", true)]
public void UserInfo(UserInfoRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
if (string.IsNullOrEmpty(callSettings.DeveloperSecretKey)) { throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "Must set DeveloperSecretKey in settings to call this method"); }
PlayFabHttp.MakeApiCall("/Matchmaker/UserInfo", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
}
}
}
#endif