Events
The ImmerseMultiplayer.OnConnectionStatusChanged
event is triggered each time the connection status is changed. As this is a static you can subscribe to this event at any time. This is in contrast to similarly named event that can be found in the INetworkClient
itself.
See the example below on how to subscribe to this event:
using ImmerseSDK.Multiplayer;
using UnityEngine;
ImmerseMultiplayer.OnConnectionStatusChanged += status =>
{
Debug.Log("Connection status is: " + status);
};
The ImmerseMultiplayer.OnInitialize
event is triggered when a connection attempt occurs. This is useful in the rare occasion that you need reference to the network client being used and need to act before the connection is made.
See the example below on how to subscribe to this event:
using ImmerseSDK.Multiplayer;
using UnityEngine;
ImmerseMultiplayer.OnInitialize += client =>
{
Debug.Log("Connecting using client of type " + client.GetType());
};
The MultiplayerConnectionStatusEventTrigger
component provides easy, serializable access to UnityEvents
that are triggered when the connection status changes. One example use of this component is to create indicators that allow users or developers to easily keep track of the connection status without requiring access to the console.
No event triggers are added when creating a new instance of this component. To track additional connection statuses, press the ‘Add New Event Type’ button at the bottom of the component in the inspector.