RTSession

The main entry point into the GameSparksRT API

clearInterval

signature clearInterval(Number intervalId)

returns void

Clears an interval using the id returned from a previous setInterval call

clearTimeout

signature clearTimeout(Number timeoutId)

returns void

Clears a timeout using the id returned from a previous setTimeout call

getLogger

signature getLogger()

returns RTLogger

Gets the logger object. Log records are written to the GameSparks collection " realtime.log"

newData

signature newData()

returns RTDataBuilder

Creates a new builder object to construct RTData objects

newPacket

signature newPacket()

returns RTPacketBuilder

Creates a new builder object to construct RTPacket objects

newRequest

signature newRequest()

returns RTRequestBuilder

A builder object for creating and sending requests to the GameSparks platform

onPacket

signature onPacket(number opCode, fn(packet: RTPacket) paramName)

returns void

Register a callback to be invoked when a packet with the given opCode is recieved. If this function does not return the supplied packet, the packet will not be sent to any players

onPlayerConnect

signature onPlayerConnect(fn(player: RTPlayer) paramName)

returns void

Register a callback to be invoked when a player connects to the session

onPlayerDisconnect

signature onPlayerDisconnect(fn(player: RTPlayer) paramName)

returns void

Register a callback to be invoked when a player disconnects from the session

getPlayer

signature getPlayer(number peerId)

returns RTPlayer

Gets a player by peerId

getPlayers

signature getPlayers()

returns RTPlayer[]

Gets all connected players

getSessionId

signature getSessionId()

returns string

Gets the current sessionId

setInterval

signature setInterval(fn() paramName, number ms)

returns Number

The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds). The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed The ID value returned by setInterval() is used as the parameter for the clearInterval() method.

setTimeout

signature setTimeout(fn() paramName, number ms)

returns Number

Calls a function or evaluates an expression after a specified number of milliseconds.

Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here