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

User List

Once you have joined a session in the Editor the list of users currently in the session can be viewed from an Editor Window accessed via Window > Immerse > User List. This can be very useful when trying to debug a multi-user application.

Customizing the User List Window

The User List window can be customized to show and hide columns, with some columns being hidden by default. You can select which columns are displayed by right-clicking anywhere on the column header. This presents a popup menu from which you can click on column categories to toggle them on or off. Columns may also be resized as needed, or automatically sized to the window width using the Resize to Fit option seen in this menu.

API

Access to this user list is also available to the application via the API, which provides a UserList object accessible viaNetworking.Client.Users 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);
        }
    }
}

Authoritative 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 a single 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 ‘Authoritative User’ feature is designed to remedy this.

The ‘Authoritative 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 ‘Authoritative User’ is stored in the User List, accessed in code underNetworking.Client.Users.AuthoritativeUser

Events

Event Description
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.
OnAuthoritativeUserChanged Triggered when the authoritative user changes. Provides the new Authoritative User as a parameter.