Immerse SDK
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Connection

The Immerse multiplayer connection is established through a websocket using Immerse’s proprietary relay server. For the simplest connection process, we recommend using the auto connect feature. This feature is enabled by default when the Multiplayer package is added.

To connect manually, follow these steps with a bit of code:

  1. Authenticate against the Immerse platform
  2. Create a INetworkClient using the CreateClient factory method
  3. Call Connect on the ImmerseMultiplayer class using your new client

The example below shows how to do this:

using ImmerseSDK.Multiplayer;

var client = ImmerseMultiplayer.CreateClient(sessionData);
var error = await ImmerseMultiplayer.Connect(client);

It is recommended to provide a cancellation token as a second parameter with the Connect method. This allows you to cancel the connection process when closing the app or exiting play mode.

To monitor your multiplayer connection status at any time, you can query the ImmerseMultiplayer.ConnectionStatus property. Combined with events, this ensures you always have visibility on your connection status.

It is recommended to enable runInBackground to prevent your connection from dropping when the application loses focus.