docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface ISession

    Namespace: Unity.Services.Multiplayer
    Assembly: Unity.Services.Multiplayer.dll
    Syntax
    public interface ISession

    Properties

    Code

    The join code of the session.

    Declaration
    string Code { get; }
    Property Value
    Type Description
    string

    CurrentPlayer

    The current player in the session.

    Declaration
    IPlayer CurrentPlayer { get; }
    Property Value
    Type Description
    IPlayer

    Host

    PlayerID of the session host.

    Declaration
    string Host { get; }
    Property Value
    Type Description
    string

    Id

    The ID of the session.

    Declaration
    string Id { get; }
    Property Value
    Type Description
    string

    IsHost

    Whether the current player is the host of the session.

    Declaration
    bool IsHost { get; }
    Property Value
    Type Description
    bool

    IsLocked

    Whether the session is locked

    Declaration
    bool IsLocked { get; }
    Property Value
    Type Description
    bool

    IsPrivate

    Whether the session is private

    Declaration
    bool IsPrivate { get; }
    Property Value
    Type Description
    bool

    MaxPlayers

    The maximum players allowed in the session

    Declaration
    int MaxPlayers { get; }
    Property Value
    Type Description
    int

    Name

    The Name of the session.

    Declaration
    string Name { get; }
    Property Value
    Type Description
    string

    Players

    The list of players in the session

    Declaration
    IReadOnlyList<IReadOnlyPlayer> Players { get; }
    Property Value
    Type Description
    IReadOnlyList<IReadOnlyPlayer>

    Properties

    The properties of the session.

    Declaration
    IReadOnlyDictionary<string, SessionProperty> Properties { get; }
    Property Value
    Type Description
    IReadOnlyDictionary<string, SessionProperty>

    State

    The current state of the Session.

    Declaration
    SessionState State { get; }
    Property Value
    Type Description
    SessionState

    Methods

    AsHost()

    Returns the session as a host session.

    Declaration
    IHostSession AsHost()
    Returns
    Type Description
    IHostSession
    Exceptions
    Type Condition
    SessionException

    Throws a Forbidden error when the caller is not the host.

    LeaveAsync()

    The leave the Session.

    Declaration
    Task LeaveAsync()
    Returns
    Type Description
    Task

    A task for the operation.

    ReconnectAsync()

    Reconnect the session.

    Declaration
    Task ReconnectAsync()
    Returns
    Type Description
    Task

    A task for the operation.

    Exceptions
    Type Condition
    SessionException

    Throws a SessionDeleted error when the session is already deleted.

    RefreshAsync()

    Refresh the session data.

    Declaration
    Task RefreshAsync()
    Returns
    Type Description
    Task

    A task for the operation.

    Exceptions
    Type Condition
    SessionException

    Throws a SessionDeleted error when the session is already deleted.

    SaveCurrentPlayerDataAsync()

    Save changes to the current player.

    Declaration
    Task SaveCurrentPlayerDataAsync()
    Returns
    Type Description
    Task

    Events

    Changed

    Event that is invoked when the session changes.

    Declaration
    event Action Changed
    Event Type
    Type Description
    Action

    Deleted

    Event that is invoked when the session is deleted.

    Declaration
    event Action<ISession> Deleted
    Event Type
    Type Description
    Action<ISession>

    PlayerJoined

    Event that is invoked when a player joins the session.

    Declaration
    event Action<string> PlayerJoined
    Event Type
    Type Description
    Action<string>

    The PlayerID of the player.

    PlayerLeft

    Event that is invoked when a player leaves the session.

    Declaration
    event Action<string> PlayerLeft
    Event Type
    Type Description
    Action<string>

    The PlayerID of the player.

    PlayerPropertiesChanged

    Event that is invoked when player properties are changed.

    Declaration
    event Action PlayerPropertiesChanged
    Event Type
    Type Description
    Action

    RemovedFromSession

    Event that is invoked when the current player is removed from the session.

    Declaration
    event Action RemovedFromSession
    Event Type
    Type Description
    Action

    SessionPropertiesChanged

    Event that is invoked when session properties are changed.

    Declaration
    event Action SessionPropertiesChanged
    Event Type
    Type Description
    Action

    StateChanged

    Event that is invoked when the session state changes.

    Declaration
    event Action<SessionState> StateChanged
    Event Type
    Type Description
    Action<SessionState>

    The new session state.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)