Beamable SDK
Public Member Functions | Public Attributes | Properties | List of all members
Beamable.Experimental.Api.Sim.SimClient Class Reference

This type defines the Client main entry point for the Multiplayer feature. More...

Collaboration diagram for Beamable.Experimental.Api.Sim.SimClient:
Collaboration graph
[legend]

Public Member Functions

delegate void EventCallback< T > (T body)
 
 SimClient (SimNetworkInterface network, long framesPerSecond, long targetNetworkLead)
 Create a new relay client that can be used to communicate with other players. More...
 
SimLog.Snapshot TakeSnapshot ()
 Create a snapshot at the current frame. More...
 
void RestoreSnapshot (SimLog.Snapshot snapshot)
 Given a SimLog.Snapshot, restore the internal simulation to that point More...
 
void SendEvent (object evt)
 Add an event to the log eventually. It won't be 'real' until it's in the log. The network decides when/how that happens This will run the SendEvent(string, object) method by using the evt's class name as the name, and the evt itself as the body More...
 
void SendEvent (string name, object evt)
 Send an event to the relay log. The event won't be validated until it round-trips through the other clients. Use the On<T> event to register a callback for when the event is put onto the log. More...
 
void Update ()
 Call this method on the Unity update loop. It will make sure to sync the relay state with the configured network frames per second.
 
Spawn< T > (SimBehavior original, string id="")
 Create a new GameObject from the given SimBehavior prefab More...
 
void RemoveSimBehavior (SimBehavior simObj)
 Remove a SimBehavior More...
 
EventCallback< string > On< T > (string evt, string origin, EventCallback< T > callback)
 Run a callback anytime a certain relay event is received onto the simulation log. More...
 
void Remove (EventCallback< string > callback)
 Remove a handler registered with the On<T> method More...
 
EventCallback< string > OnInit (EventCallback< string > callback)
 Add a callback that will trigger after the relay has been initialized. More...
 
EventCallback< string > OnConnect (EventCallback< string > callback)
 Add a callback that will trigger after each player joins the game relay. More...
 
EventCallback< string > OnDisconnect (EventCallback< string > callback)
 Add a callback that will trigger after a player disconnects from the game realy. More...
 
EventCallback< string > OnTick (EventCallback< long > callback)
 Add a callback that will trigger on every network tick More...
 
int RandomInt ()
 Get a deterministically random number. The seed for the random values is shared among all players in the relay. If all clients use this method to get random values, then all clients will get the same random values. More...
 

Public Attributes

SimNetworkInterface Network
 

Properties

int LogHash [get]
 
int StateHash [get]
 
long Ping [get]
 
string ClientId [get]
 

Detailed Description

This type defines the Client main entry point for the Multiplayer feature.

Related Links

img beamable-logo

Constructor & Destructor Documentation

◆ SimClient()

Beamable.Experimental.Api.Sim.SimClient.SimClient ( SimNetworkInterface  network,
long  framesPerSecond,
long  targetNetworkLead 
)
inline

Create a new relay client that can be used to communicate with other players.

Parameters
networkA SimNetworkInterface that controls how the events are passed between players.
framesPerSecondA target network frame rate.
targetNetworkLeadNumber of frames desired for the network to be ahead of the live simulation

Member Function Documentation

◆ On< T >()

EventCallback< string > Beamable.Experimental.Api.Sim.SimClient.On< T > ( string  evt,
string  origin,
EventCallback< T >  callback 
)
inline

Run a callback anytime a certain relay event is received onto the simulation log.

Parameters
evtThe type of event
originthe origin string for who sent the event
callbackA callback to run when the event is recieved
Template Parameters
TThe type to deserialize the event json into
Returns
An object that can be given to Remove to remove the handler

◆ OnConnect()

EventCallback< string > Beamable.Experimental.Api.Sim.SimClient.OnConnect ( EventCallback< string >  callback)
inline

Add a callback that will trigger after each player joins the game relay.

Parameters
callbacka callback where the only argument is the gamertag of the player that joined.
Returns
An instance that can be sent to the Remove method to remove the handler.

◆ OnDisconnect()

EventCallback< string > Beamable.Experimental.Api.Sim.SimClient.OnDisconnect ( EventCallback< string >  callback)
inline

Add a callback that will trigger after a player disconnects from the game realy.

Parameters
callbacka callback where the only argument is the gamertag of the player that disconnected.
Returns
An instance that can be sent to the Remove method to remove the handler.

◆ OnInit()

EventCallback< string > Beamable.Experimental.Api.Sim.SimClient.OnInit ( EventCallback< string >  callback)
inline

Add a callback that will trigger after the relay has been initialized.

Parameters
callbackA callback where the only argument is the relay room id
Returns
An instance that can be sent to the Remove method to remove the handler.

◆ OnTick()

EventCallback< string > Beamable.Experimental.Api.Sim.SimClient.OnTick ( EventCallback< long >  callback)
inline

Add a callback that will trigger on every network tick

Parameters
callbackA callback where the only argument is the current tick number of the simulation
Returns
An instance that can be sent to the Remove method to remove the handler.

◆ RandomInt()

int Beamable.Experimental.Api.Sim.SimClient.RandomInt ( )
inline

Get a deterministically random number. The seed for the random values is shared among all players in the relay. If all clients use this method to get random values, then all clients will get the same random values.

Returns
A number

◆ Remove()

void Beamable.Experimental.Api.Sim.SimClient.Remove ( EventCallback< string >  callback)
inline

Remove a handler registered with the On<T> method

Parameters
callbackThe instance returned from the On<T> method

◆ RemoveSimBehavior()

void Beamable.Experimental.Api.Sim.SimClient.RemoveSimBehavior ( SimBehavior  simObj)
inline

Remove a SimBehavior

Parameters
simObj

◆ RestoreSnapshot()

void Beamable.Experimental.Api.Sim.SimClient.RestoreSnapshot ( SimLog.Snapshot  snapshot)
inline

Given a SimLog.Snapshot, restore the internal simulation to that point

Parameters
snapshotA SimLog.Snapshot generated with the TakeSnapshot method

◆ SendEvent() [1/2]

void Beamable.Experimental.Api.Sim.SimClient.SendEvent ( object  evt)
inline

Add an event to the log eventually. It won't be 'real' until it's in the log. The network decides when/how that happens This will run the SendEvent(string, object) method by using the evt's class name as the name, and the evt itself as the body

Parameters
evtAny json serializable object

◆ SendEvent() [2/2]

void Beamable.Experimental.Api.Sim.SimClient.SendEvent ( string  name,
object  evt 
)
inline

Send an event to the relay log. The event won't be validated until it round-trips through the other clients. Use the On<T> event to register a callback for when the event is put onto the log.

Parameters
nameA name for the event. This can be any string, but should be a consistent channel name.
evtAny json serializable object. The object will be sent to JSON and sent to the relay server.

◆ Spawn< T >()

T Beamable.Experimental.Api.Sim.SimClient.Spawn< T > ( SimBehavior  original,
string  id = "" 
)
inline

Create a new GameObject from the given SimBehavior prefab

Parameters
original
id
Template Parameters
T
Returns

◆ TakeSnapshot()

SimLog.Snapshot Beamable.Experimental.Api.Sim.SimClient.TakeSnapshot ( )
inline

Create a snapshot at the current frame.

Returns
A SimLog.Snapshot contains all of the SimEvent for all frames

The documentation for this class was generated from the following file: