Skip to main content

Network Events

There are some events pre-defined by the SDK that developers can attach callbacks to. You might’ve come across a couple of them while going through this guide such as OnHostAppointment .

This document will list all the network events that you can attach callbacks to.

IGameSession Events

OnHostAppointment

public delegate void HostAppointmentEvent();
public event HostAppointmentEvent OnHostAppointment;

This event will be triggered when a client is appointed as the host by the game server. This will happen either when the first client joins a game session, or on another client after the previous host got disconnected.

OnDisconnected

public delegate void DisconnectionEvent(Player player);
public event DisconnectionEvent OnDisconnected;

This event will be triggered whenever there is a player that gets disconnected from the game session.

OnLocalPlayerDisconnected

public delegate void LocalPlayerEvent();
public event LocalPlayerEvent OnLocalPlayerDisconnected;

This event will only be triggered when the local player/client is disconnected.

OnPlayerListChanged

public delegate void PlayerListChangedEvent(ICollection<Player> players);
public event PlayerListChangedEvent OnPlayerListChanged;

This event will be triggered whenever there is a change in the list of players. It could trigger when there is a new player that joins, or leaves the game session.

OnPlayerJoined

public delegate void PlayerEvent(Player player);
public event PlayerEvent OnPlayerJoined;

This event will be triggered whenever there is a new player that joins the game session.

OnLocalPlayerJoined

public delegate void LocalPlayerEvent();
public event LocalPlayerEvent OnLocalPlayerJoined;

This event will be triggered when the local player/client successfully joins the game session.

NetworkSpawner Events

OnLocalPlayerInstantiated

public delegate void InstantiateEvent(NetworkIdentity networkIdentity);
public event InstantiateEvent OnLocalPlayerInstantiated;

This event will only be triggered when there is a prefab that is instantiated with NetworkSpawner, and the owner of this instance is the same client that makes the instantiation call.

OnInstantiated

public delegate void InstantiateEvent(NetworkIdentity networkIdentity);
public event InstantiateEvent OnInstantiated;

This event will be triggered whenever there is a prefab that is instantiated, regardless of which client starts the instantiation process.

NetworkCamera Events

OnLocalProxyReady

public delegate void LocalProxyReadyEvent(Transform localProxy);
public event LocalProxyReadyEvent OnLocalProxyReady;

We haven’t got to the details on what a NetworkCamera is, and how it works. But the gist is that this is a component attached to a Camera object. By adding this component, every connected client will have a proxy of all connected clients' camera pose. These proxies' pose will be updated by the SDK on every LateUpdate. This event will be triggered after the proxy for the local client is initialized properly on all connected clients.