Immerse

Synchronising state between users

Securely synchronising state (or data) between users is a core component of the Immerse Platform. The SDK provides out-of-the-box synchronisation for standard Interactions, such as moving a dial or picking up an object.

Consider more complex actions such as:

  • programmatically turning on a light, when a set of user tasks have been completed
  • instantiating objects at runtime
  • sharing a random seed
  • initiating a timer and triggering an event which occurs at the end of the period

For occurrences such as these, the Immerse SDK provides two ways to synchronise state across the platform:

  1. StateSynchroniser
  2. Custom messages

StateSynchroniser

There are two types of StateSynchroniser; the process for implementing them is the same:

  • The StateSynchroniser synchronises single basic type such as string, bool, int, float and byte array
  • The ObjectStateSynchroniser synchronises an object (defined as a serialised JSON string). By combining all values in an object, multiple values can be synchronised simultaneously.

To use:

  1. Inherit from StateSynchroniseror ObjectStateSynchroniser
  2. Implement the ReceivedSynchronisedMessagemethod to deal with the data change
  3. Call SendSynchronisedMessage with the data that needs to be synced

📘

Immerse SDK Class Library

More detail available in
StateSynchroniser

ObjectStateSynchroniser

ReceivedSynchronisedMessage

SendSynchronisedMessage

Why use a StateSynchroniser?

  • Messages are persisted, so users joining a session late will receive objects and data in the scene synchronised with all other users

  • Significantly easier to use than Custom messages, which must be first registered with the CustomMessageManager and manually converted into bytes. Additionally Custom Messages must be manually configured when uploading the Immerse Scene to the Platform.

Why use Custom Messages?

Learn more about Custom messages

🚧

StateSynchroniser vs Custom Messages

To synchronise data across users in a session, it is recommended that the StateSynchroniser component is used, rather than Custom Messages

Unity iconTry out this component in the Examples project

Examples (menu) > Network > Load Synchronised Instantiation Example

Learn more about the Examples project

Updated 4 months ago


Synchronising state between users


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.