Real-Time Gameplay Configuration
This article will walk you through setting up your game for real-time gameplay on Skillz. Make sure you have implemented the Skillz Delegate before proceeding. We recommend reviewing the documentation for Standard Gameplay in order to understand the basics of the Skillz SDK integration.
Overview​
Skillz Real-Time games are those where players are actively in a session together, competing in real-time.
Skillz supports multiplayer games in the following configurations:
- Using our integration with Photon Quantum Networking
- Implementing a custom game server
- Using our integration with Photon Unity Networking (PUN)
Below we will briefly describe the high level architecture on how we support multiplayer games on the Skillz platform.
Sync Architecture​
- Photon Quantum
- Custom Server
- PUN
See our integration with Photon Quantum Networking for more information.
The Skillz custom server synchronous technology is based on a server authoritative model. That is, an authoritative game server owns the game state to help protect against unauthorized operations by a client (e.g. cheating). Skillz hosts the servers on a scalable cloud hosting solution which you have the option to customize based upon your games needs.
We currently use AWS Amazon Elastic Compute Cloud (or EC2) instances and Kubernetes (or K8s) to host our platform.
The diagram below provides an overview of the key components:

Skillz real-time technology integration with PUN is based on a client authoritative model. One client is designated the master and serves as the authority. Photon's hosted servers, act as relays between the master client and the others. More information about PUN can be found on their website
The diagram below provides an overview of the key components:

Server Requirements​
- Photon Quantum
- Custom Server
- PUN
Photon Quantum uses cloud servers hosted by Photon. There are no server requirements necessary on your part to get started.
For information on integrating with Photon Quantum see our integration with Photon Quantum Networking.
To support a real-time game server on the Skillz platform, Skillz requires the following:
- A game server must be provided via a Docker Image Archive (tar.gz file) for deployment.
- The game server must be Linux based.
- It must be able to run as a non-root user.
Skillz supports both Ephemeral and Room-based server architecture. Based on which architecture you choose there are additional requirements.
- Ephemeral
- Room Based
- The server application must exit the process at the end of the match.
- The Server application must also exit the process if the match never starts or is ended prematurely (e.g. such if one player never shows up in a 1:1 match).
- The server must expose only a single port over IPv4 or IPv6.
- We support UDP + TCP protocols.
- A game server must be able to service multiple clients simultaneously on a single server instance.
- A game server must expose only a single TCP/IP port that is TLS-enabled over IPv4.
PUN uses cloud servers hosted by Photon. There are no server requirements necessary on your part to get started.
However, PUN is only available as a Unity package, and is not available for use with the native Android or iOS SDK. If your app is build in native Android or iOS, please look into one of our other real-time technology options.
Developer Workflow​
- Photon Quantum
- Custom Server
- PUN
- Build a real-time game using Photon Quantum. You can use a free Photon cloud account from photon while developing. Use our integration with Photon Quantum Networking as a starting point for faster and easier integration with Skillz.
- Test your game connectivity with Quantum by using a dummy name for the room information received client-side from the Skillz SDK.
- Please reference the Testing Real-Time Games section for common use cases to test against.
- Once you have verified things work locally, work with the Skillz team to spin up a Sandbox Sync template to validate the workflow.
- Once Sandbox testing is complete, Skillz will work with you to rollout the game into production.
- Build your Real-Time Gameplay server.
- Integrate the Skillz SDK.
- Test your game connectivity with your server running locally by hard coding the connection received client-side from the Skillz SDK.
- Please reference the Testing Real-Time Games section for common use cases to test against.
- Once you have verified things work locally, work with the Skillz team to spin up a Sandbox server to validate the workflow.
- Once Sandbox testing is complete, Skillz will work with you to rollout the game into production.
- Build a Real-Time game using PUN. You can use a free account from photon while developing.
- Integrate the Skillz SDK
- Test your game connectivity with PUN by hard coding the room information received client-side from the Skillz SDK.
- Please reference the Testing Real-Time Games section for common use cases to test against.
- Once you have verified things work locally, work with the Skillz team to spin up a Sandbox Sync template to validate the workflow.
- Once Sandbox testing is complete, Skillz will work with you to rollout the game into production.
Creating a Custom Real-Time Gameplay Server​
- Photon Quantum
- Custom Server
- PUN
With Photon Quantum, Photon takes cares of all the server work for you. You just need a Photon Cloud AppID.
For information on integrating with Photon Quantum see our integration with Photon Quantum Networking.
There are many great options for building out custom Real-Time Gameplay servers. Some options include:
With Pun, Photon takes cares of all the server work for you. All you need to do is import the PUN 2 Package into Unity and follow these steps to get a access to a hosted server.
Real-Time Gameplay Integration​
The Skillz Client SDK integration will be the same as for play-and-compare game modes. The difference comes with how you handle things when the match begins. Once the match begins you will need to validate the match is a real-time match then connect to the game server and start sending and receiving game state updates based upon your needs.
Currently we only have Unity example apps. You can still implement your real-time game utilizing the Skillz iOS or Android SDKs. Work with the Skillz team to answer questions regarding your specific platform.
Starting a Game (Match Start)​
- Photon Quantum
- Custom Server
- PUN
For information on integrating with Photon Quantum see our integration with Photon Quantum Networking.
When a match begins the Skillz SDK will call the OnMatchWillBegin method (Unity implementation). Use matchInfo.IsCustomSynchronousMatch to determine if the present match is a real-time match. Then proceed to check the Match object to see if you have a server IP and port. If so, you have a real-time match and can connect to the server and begin your game logic. If not you simply have an play-and-compare match and can continue accordingly.
Please note that the MatchId from the CustomServerConnectionInfo instance is the unique id for the sync match. This will be the same for the matched players and should be used to send the players to the same room.
string matchID = matchInfo.CustomServerConnectionInfo.MatchId;
::: caution If you are building an ephemeral game server, the client will receive the IP in the following format: {IPv4,IPv6}. This will require the client to parse this value and handle connecting over IPv6 or IPv4 as desired.
Example: {"ip":"18.236.89.133,2600:1f13:2aa:4600:2735:6920:31c5:8812"}
:::
void SkillzMatchDelegate.OnMatchWillBegin(Match matchInfo)
{
// Please note Unity provides a helper property to determine the match type
// if IsCustomSynchronousMatch is true we have a sync v2 match
if (matchInfo.IsCustomSynchronousMatch)
{
// get the needed info and handle your real-time game start
string matchID = matchInfo.CustomServerConnectionInfo.MatchId;
string hostName = matchInfo.CustomServerConnectionInfo.ServerIp;
string port = matchInfo.CustomServerConnectionInfo.ServerIp;
// ...
}
else
{
// handle your async game start
}
}
When a match begins the Skillz SDK will call the OnMatchWillBegin method (Unity implementation). Use matchInfo.IsCustomSynchronousMatch to determine if the present match is a real-time match. If so, you have a real-time match and can connect to Photon Server, Join a room and begin your game logic. If not you simply have an async match and can continue accordingly.
Please note that the MatchId from the CustomServerConnectionInfo instance is the unique id for the sync match. This will be the same for the matched players and should be used to send the players to the same room.
string matchID = matchInfo.CustomServerConnectionInfo.MatchId;
public sealed class SkillzGameController : SkillzMatchDelegate
{
public void OnMatchWillBegin(Match matchInfo)
{
// Please note Unity provides a helper property to determine the match type
// if IsCustomSynchronousMatch is true we have a sync v2 match
if (matchInfo.IsCustomSynchronousMatch)
{
SceneManager.LoadScene(SyncGameScene);
// ...
}
else
{
// handle your async game start
SceneManager.LoadScene(ASyncGameScene);
}
}
public sealed class SyncGameController : MonoBehaviourPunCallbacks
{
//keep track of connection status
bool isConnecting;
public void ConnectToPUN()
{
// #Critical, we must first and foremost connect to Photon Master Server.
//Will call OnConnectedToMaster() on successful connection
isConnecting = PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
if (isConnecting)
{
// #Critical: The first we try to do is to join the room or create the room if it doesn't exist
Debug.Log("First time connecting to Master Server, creating and joining room");
//use sync match id as the room name
string skillzRoomName = SkillzCrossPlatform.GetMatchInfo().CustomServerConnectionInfo.MatchId;
PhotonNetwork.JoinOrCreateRoom(skillzRoomName, new RoomOptions { MaxPlayers = 2 }, default);
isConnecting = false;
}
}
}
Reporting Scores​
Depending on your specific game setup, we provide either client-side or server-side score reporting.
Client-Side Score Reporting​
For client-side score reporting, you submit scores the same way you would for an play-and-compare game. Please read our score submitting docs for step-by-step instructions.
Server-Side Score Reporting​
- Photon Quantum
- Custom Server
- PUN
Skillz is currently looking into supporting server side score reporting with Photon Quantum.
For information on integrating with Photon Quantum see our integration with Photon Quantum Networking.
The Sync Event Service is responsible for handling HTTP POST requests from Sync game servers hosted on the Skillz platform. The URI of the service is exposed as an environment variable EVENT_SERVICE, while the endpoint for reporting scores is /realtime/v1/scores. (The full URI of the report-score endpoint is thus ${EVENT_SERVICE}/realtime/v1/scores.)
Your Skillz Game ID must be included as a header. For convenience, your game ID is exposed as an environment variable SKILLZ_GAME_ID. The header must be included as X-Skillz-GameId (see below for examples). In the future, this requirement will be removed and the Skillz platform will handle the inclusion of this Game ID header.
JSON Payload​
The payload is sent as JSON and follows this schema:
matchmaker_match_id- The match UUID sent down by the Skillz Matchmaker to both clients upon finding a successful matchscores- List of two JSON objects, each containing the following values:user_id- User ID of the playerscore- Score for this playerabort_state- If the user has aborted, we omitscoreand instead include a value ofUNKNOWNfor abort_state. In the future, this functionality will be expanded to allow for more verbose abort states
::: warning
- The
matchmaker_match_idmust be included with all requests. - At least one of the scores objects must include a
user_id. (This might be the case if only one player were to ever connect to the match.) - Either a
scoreorabort_statemust be sent for a given player. Including both ascoreandabort_stateobject will result in an invalid request. ::: Below are examples of valid requests:
- Two Scores
- One Score and One Abort
- Two Aborts
- Only One Player Connected
{
"matchmaker_match_id": "f7c1e04f-6dc2-4af3-a875-5bdf541ae7c5",
"scores": [
{
"user_id": 2021938685,
"score": 100
},
{
"user_id": 14117213,
"score": 9001
}
]
}
{
"matchmaker_match_id": "f7c1e04f-6dc2-4af3-a875-5bdf541ae7c5",
"scores": [
{
"user_id": 2021938685,
"abort_state": "UNKNOWN"
},
{
"user_id": 14117213,
"score": 9004
}
]
}
{
"matchmaker_match_id": "f7c1e04f-6dc2-4af3-a875-5bdf541ae7c5",
"scores": [
{
"user_id": 2021938685,
"abort_state": "UNKNOWN"
},
{
"user_id": 14117213,
"abort_state": "UNKNOWN"
}
]
}
{
"matchmaker_match_id": "f7c1e04f-6dc2-4af3-a875-5bdf541ae7c5",
"scores": [
{
"user_id": 2021938685,
"score": 0
},
{
"abort_state": "UNKNOWN"
}
]
}
Example Implementation​
Below is an example of reporting score in Groovy:
In the following example, the EventReporter class exposes the following public methods:
reportScores(Long userId, Long userScore, Long opponentId, Long opponentScore, String matchmakerMatchId)
reportScoreAndAbort(Long userId, Long userScore, Long abortingOpponentId, String matchmakerMatchId)
reportDoubleAbort(Long abortingUserId, Long abortingOpponentId, String matchmakerMatchId)
Implementation​
import com.google.gson.FieldNamingPolicy
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import io.netty.handler.codec.http.HttpResponseStatus
import okhttp3.MediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.Response
@CompileStatic
class Event {
String matchmakerMatchId
}
@CompileStatic
class ScoreEvent extends Event {
List<Score> scores
}
@CompileStatic
class Score extends Event {
Long userId
Long score
String abortState
}
@Slf4j
@CompileStatic
class EventReporter {
private static final String EVENT_SERVICE = System.getenv('EVENT_SERVICE')
private static final String GAME_ID = System.getenv('SKILLZ_GAME_ID')
private static final String REPORT_SCORE_ENDPOINT = "/realtime/v1/scores"
private static final MediaType JSON = MediaType.get("application/json; charset=utf-8")
private static final int MAX_REQUEST_RETRIES = 3
private final OkHttpClient client = new OkHttpClient()
private final Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create()
void reportScores(Long userId, Long userScore, Long opponentId, Long opponentScore, String matchmakerMatchId) {
ScoreEvent scoreEvent = new ScoreEvent(
matchmakerMatchId: matchmakerMatchId,
scores: [
new Score(
userId: userId,
score: userScore
),
new Score(
userId: opponentId,
score: opponentScore
)])
log.debug("Reporting score for matchmaker match ID ${matchmakerMatchId}")
postEventWithRetry(REPORT_SCORE_ENDPOINT, scoreEvent)
}
void reportScoreAndAbort(Long userId, Long userScore, Long abortingOpponentId, String matchmakerMatchId) {
ScoreEvent abortEvent = new ScoreEvent(
matchmakerMatchId: matchmakerMatchId,
scores: [
new Score(
userId: userId,
score: userScore
),
new Score(
userId: abortingOpponentId,
abortState: "UNKNOWN"
)])
log.debug("Reporting score for matchmaker match ID ${matchmakerMatchId}")
postEventWithRetry(REPORT_SCORE_ENDPOINT, abortEvent)
}
void reportDoubleAbort(Long abortingUserId, Long abortingOpponentId, String matchmakerMatchId) {
ScoreEvent abortEvent = new ScoreEvent(
matchmakerMatchId: matchmakerMatchId,
scores: [
new Score(
userId: abortingUserId,
abortState: "UNKNOWN"
),
new Score(
userId: abortingOpponentId,
abortState: "UNKNOWN"
)])
log.debug("Reporting score for matchmaker match ID ${matchmakerMatchId}")
postEventWithRetry(REPORT_SCORE_ENDPOINT, abortEvent)
}
private void postEventWithRetry(String endpoint, Event event, int retries = 0) {
try {
if (retries >= MAX_REQUEST_RETRIES) {
log.error("Request to submit score was not accepted after ${retries} failures for matchmaker match ID ${event.matchmakerMatchId}!")
return
}
Response response = postEvent(endpoint, event)
if (response.code() != HttpResponseStatus.ACCEPTED.code()
&& response.code() != HttpResponseStatus.BAD_REQUEST.code()
&& response.code() != HttpResponseStatus.UNPROCESSABLE_ENTITY.code()) {
log.error("Request to submit score was not accepted for matchmaker match ID ${event.matchmakerMatchId}:\n${response.code()} - ${response.body()}")
postEventWithRetry(endpoint, event, ++retries)
}
} catch (IOException e) {
log.error("Exception thrown while attempting to report score for matchmaker match ID ${event.matchmakerMatchId}:\n${e.toString()}")
postEventWithRetry(endpoint, event, ++retries)
}
}
private Response postEvent(String endpoint, Event event) throws IOException {
def json = gson.toJson(event)
log.debug("Sending POST HTTP request to endpoint: ${endpoint} with json: ${json}")
RequestBody body = RequestBody.create(json, JSON)
Request request = new Request.Builder()
.url("https://" + EVENT_SERVICE + endpoint)
.header("X-Skillz-GameId", GAME_ID)
.post(body)
.build()
try (Response response = client.newCall(request).execute()) {
return response
}
}
}
PUN does not support server side score reporting. You must use client score reporting.
Setting up Sandbox Real-Time Templates​
- Photon Quantum
- Custom Server
- PUN
Run the following commands in your terminal
IMAGE_NAME="INSERT_IMAGE_NAME_HERE"
# Go to directory with Dockerfile
cd <FOLDER_WITH_DOCKERFILE>
# Build container image
docker build -t ${IMAGE_NAME} .
# Create image archive
docker save -o ./${IMAGE_NAME}-$(date +%Y%m%dT%H%M%S).tar.gz ${IMAGE_NAME}
The final image archive file will have the name of ${IMAGE_NAME}-$(date +%Y%m%dT%H%M%S).tar.gz. This image archive will be used to deploy your Sync Server on Skillz infrastructure.
Documentation for the docker save command is available on their website
Contacting Skillz​
Now that you are ready, please contact us](https://developers.skillz.com/support/contact_us) and request the Skillz Sync Server functionality to be enabled.