com.playfab.PlayFabMatchmakerAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of server-sdk Show documentation
Show all versions of server-sdk Show documentation
PlayFab is the unified backend platform for games — everything you need to build and operate your game, all in one place, so you can focus on creating and delivering a great player experience.
package com.playfab;
import com.playfab.internal.*;
import com.playfab.PlayFabMatchmakerModels.*;
import com.playfab.PlayFabErrors.*;
import com.playfab.PlayFabSettings;
import java.util.concurrent.*;
import java.util.*;
import com.google.gson.*;
import com.google.gson.reflect.*;
/** Enables the use of an external match-making service in conjunction with PlayFab hosted Game Server instances */
public class PlayFabMatchmakerAPI {
private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
/**
* Validates a user with the PlayFab service
* @param request AuthUserRequest
* @return Async Task will return AuthUserResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> AuthUserAsync(final AuthUserRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAuthUserAsync(request);
}
});
}
/**
* Validates a user with the PlayFab service
* @param request AuthUserRequest
* @return AuthUserResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AuthUser(final AuthUserRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAuthUserAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Validates a user with the PlayFab service */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAuthUserAsync(final AuthUserRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask