ドキュメント

Multiplayer Services SDK

All Services

Multiplayer Services SDK

Session states

Reference the lifecycle states a session can be in while it's created, connected, and removed.
読み終わるまでの所要時間 1 分最終更新 12時間前

The
SessionState
enum represents the current lifecycle state of a multiplayer session. Use the session's
State
property or subscribe to
StateChanged
to react when a session transitions between states.
A session can be in one of the following states:

State

Description

When to use

None
The session has no active lifecycle state assigned yet, or no session state has been established.Before a session is fully initialized or after the session has been reset.
Connected
The session is active and the client is connected to the session.During normal gameplay or while a session is available for players to participate in.
Disconnected
The session was connected but is no longer connected or is temporarily unavailable.During network disruption, connection loss, or session reconnection handling.
Deleted
The session has been removed or deleted and is no longer valid for use.After the session has been closed or cleaned up.

When to use this state information

Check the current state when your game logic depends on whether the session is usable, reconnecting, or already invalid. For example, you might defer gameplay setup until a session reaches
Connected
, show reconnect UI while a session is
Disconnected
, and stop all operations when the state becomes
Deleted
.
The following example listens for state changes and logs the current lifecycle state:
void OnSessionStateChanged(SessionState newState) { Debug.Log($"Session state changed: {newState}");}session.StateChanged += OnSessionStateChanged;

Additional resources