
com.playfab.PlayFabEventsAPI 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.PlayFabEventsModels.*;
import com.playfab.PlayFabErrors.*;
import com.playfab.PlayFabSettings;
import java.util.concurrent.*;
import java.util.*;
import com.google.gson.*;
import com.google.gson.reflect.*;
/**
* Write custom PlayStream and Telemetry events for any PlayFab entity. Telemetry events can be used for analytic,
* reporting, or debugging. PlayStream events can do all of that and also trigger custom actions in near real-time.
*/
public class PlayFabEventsAPI {
private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
/**
* Write batches of entity based events to PlayStream. The namespace of the Event must start with 'com.playfab.events.'
* @param request WriteEventsRequest
* @return Async Task will return WriteEventsResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> WriteEventsAsync(final WriteEventsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateWriteEventsAsync(request);
}
});
}
/**
* Write batches of entity based events to PlayStream. The namespace of the Event must start with 'com.playfab.events.'
* @param request WriteEventsRequest
* @return WriteEventsResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult WriteEvents(final WriteEventsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateWriteEventsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Write batches of entity based events to PlayStream. The namespace of the Event must start with 'com.playfab.events.' */
@SuppressWarnings("unchecked")
private static PlayFabResult privateWriteEventsAsync(final WriteEventsRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask
© 2015 - 2025 Weber Informatics LLC | Privacy Policy