Session states
Reference the lifecycle states a session can be in while it's created, connected, and removed.
読み終わるまでの所要時間 1 分最終更新 12時間前
The enum represents the current lifecycle state of a multiplayer session. Use the session's property or subscribe to to react when a session transitions between states.
SessionStateStateStateChangedA session can be in one of the following states:
State | Description | When to use |
|---|---|---|
| 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. |
| 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. |
| The session was connected but is no longer connected or is temporarily unavailable. | During network disruption, connection loss, or session reconnection handling. |
| 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 , show reconnect UI while a session is , and stop all operations when the state becomes .
ConnectedDisconnectedDeletedThe 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;