Understanding GameSparks Real-Time

This tutorial provides an introductory overview for working with GameSparks Real-Time.

Realtime Availability? The Realtime feature is no longer available to games created on or after February 19th, 2019, or for games created before February 19th, 2019 that had not yet used the feature. If you require Realtime for your game and do not have access under your current plan, please contact us to discuss the Enterprise Pricing Tier.

Creating a Real-Time session

Real-Time sessions are dependent on Real-Time Matches. A Match must be configured to support a real-time session once it is found. When a Match has been found, a MatchFoundMessage will be sent to the players involved with three important variables:

These three variables are what a client needs to establish a connection to the Real-Time session.

The GameSparks SDK has the Create Session function that allows you to connect to a session using the Port Number, Access Token, and Host Server.

The session comes with four useful Events, which help you to organize players, manage games and logic, and use data sent to or from the server or other peers:

In addition to these Events, you also have Stop, Start, GetPeers and Send functions:

Packets and Connection

Real-Time sessions have access to every part of the backend and can execute logic on behalf of any player. You can add logic to your server by creating a Real-Time script in the Cloud Code section and configuring the Match to use that script.

You can place logic in the script that reacts to packets, to players connecting, and to players disconnecting using the same functions:

The packets sent and received have four attributes:

Important! Note that OpCode 0 Does not work. Do not address Packets with OpCode 0.


To retrieve Data from a packet you would use Has Type and Get Type functions. For example, if you were trying to retrieve a string from index 20 you would: