HomeGuides
HomeGuidesLearn about the Immerse SDK installerLog In

User List

📘

This feature requires the Immerse SDK Enterprise Edition

This is different to the free Immerse SDK. Contact [email protected] if you require access.

Understand the difference between the Free and Enterprise SDK

The list of users in a session is can be seen from the User List window found in Window > Immerse > User List. This provides information about each user that's in the current session from the Unity Editor. This can be very useful when trying to debug a multi-user application.

API

Access to this user list is also available to the application via the API. This information and the provided events are very powerful and are used extensively throughout the SDK.

Example

Below is an example script that demonstrates how to access the user list, by printing the name of each user currently in the session to the console.

using System.Collections;
using ImmerseSDK.PlatformServices;
using ImmerseSDK.PlatformServices.Multiuser;
using ImmerseSDK.PlatformServices.Multiuser.Users;
using UnityEngine;

/// <summary>
/// An example script that will list all users in a session once connected
/// </summary>
public class ListAllUsers : MonoBehaviour
{
    public IEnumerator Start()
    {
        // Wait until the session is connected before trying to access the user list
        yield return new WaitForConnectionStatus(ConnectionStatus.Connected);

        // Iterate through all users in the session
        foreach (User user in Networking.Client.Users)
        {
            // Print the user's name
            Debug.Log(user.Name);
        }
    }
}

Executive User

Immerse multi-user sessions are hosted on a server as opposed to a host user. This provides many benefits, but one limitation it imposes is the inability to identify user as a host. This identification can be very useful when creating an experience where only one user should be in control of a feature, such as a state change event in a state machine. The 'Executive User' feature is designed to remedy this.

The 'Executive User' is always the same for all clients connected to the session and exposed events are triggered should the user change (see below). The current 'Executive User' is stored in the User List. Networking.Client.Users.ExecutiveUser

Events

OnUserConnected

Triggered when a new user connects. Provides the connecting user as a parameter.

OnUserDisconnected

Triggered when a user disconnects. Provides the disconnecting user as a parameter.

OnExecutiveUserChanged

Triggered when the executive user changes. Provides the new Executive User as a parameter.