# Realtime

Realtime is a component that manages your connection to a room, as well as any RealtimeViews that should be connected to the room’s datastore.

# Editor Interface

App Key: This is a unique key used to track your apps usage. You can create one over on your account dashboard (opens new window).

Join Room On Start + Room Name: If you would like Realtime to automatically connect to a room on Start, you can check this box and enter the room name here.

Note: Room names are namespaced to your App Key. Any room name used with a different App Key is considered a different room by the server.

Debug Logging: Our native plugin offers a more verbose logging mode. This can be useful when debugging low-level networking bugs. It’s rare that you will need to use this, but if you’re submitting a bug report to the Normal team, leave this turned on so we can properly diagnose the issue.

Network Statistics: The network statistics section shows you the current network statistics for the current connection. It includes things like packet loss %, bandwidth measurements, and the current room clock time.

Properties

int clientID

int Normal.Realtime.Realtime.clientID

The ID of the local client on the server. If this client is not connected, this value will be -1.

bool connected

bool Normal.Realtime.Realtime.connected

bool connecting

bool Normal.Realtime.Realtime.connecting

bool disconnected

bool Normal.Realtime.Realtime.disconnected

HashSet<Realtime> instances

HashSet<Realtime> Normal.Realtime.Realtime.instances

Room room

Room Normal.Realtime.Realtime.room

A Room object that represents the data model for the room. This can be useful for getting the current room time that has been synchronized with the server. You can use this property to pass an instance of Room off to another instance of Realtime.

Methods

void Connect (string roomName, IModel roomModel=null)

void Normal.Realtime.Realtime.Connect

void Destroy (GameObject gameObject)

static void Normal.Realtime.Realtime.Destroy

This method destroys a prefab in the scene that has been instantiated using Instantiate(). It will destroy the prefab locally as well as on all remote clients.

void Destroy (RealtimeView realtimeView)

static void Normal.Realtime.Realtime.Destroy

This method destroys a prefab in the scene that has been instantiated using Instantiate(). It will destroy the prefab locally as well as on all remote clients.

void Disconnect ()

void Normal.Realtime.Realtime.Disconnect

GameObject Instantiate (string prefabName, Realtime useInstance)

static GameObject Normal.Realtime.Realtime.Instantiate

GameObject Instantiate (string prefabName, bool ownedByClient=true, bool preventOwnershipTakeover=false, bool destroyWhenOwnerOrLastClientLeaves=true, Realtime useInstance=null)

static GameObject Normal.Realtime.Realtime.Instantiate

Instantiates a prefab that has a RealtimeView at the root. Calling this method will lookup the prefab by name and instantiate it on all clients.

GameObject Instantiate (string prefabName, Vector3 position, Quaternion rotation, bool ownedByClient=true, bool preventOwnershipTakeover=false, bool destroyWhenOwnerOrLastClientLeaves=true, Realtime useInstance=null)

static GameObject Normal.Realtime.Realtime.Instantiate

Instantiates a prefab that has a RealtimeView at the root. Calling this method will lookup the prefab by name and instantiate it on all clients. This method will automatically set the position and rotation of the prefab. If a RealtimeTransform component is present on the root, it will request ownership so the position and rotation are synchronized to all clients.

delegate void RealtimeEvent (Realtime realtime)

delegate void Normal.Realtime.Realtime.RealtimeEvent

Events

RealtimeEvent didConnectToRoom

RealtimeEvent Normal.Realtime.Realtime.didConnectToRoom

RealtimeEvent didDisconnectFromRoom

RealtimeEvent Normal.Realtime.Realtime.didDisconnectFromRoom