Documentation

LobbyApi

Import

Import

  • const { LobbyApi } = require("@unity-services/lobby-1.2");

Constructors

Constructor

  • Parameters

    • Optional configuration: Configuration
    • basePath: string = ...
    • axios: AxiosInstance = ...

    Returns LobbyApi

Methods

Bulk Update Lobby

  • bulkUpdateLobby(lobbyId: string, serviceId?: string, impersonatedUserId?: string, bulkUpdateRequest?: BulkUpdateRequest, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Apply a bulk update to a lobby. This can modify the lobby's metadata, add players, update players, and remove players. This operation is only allowed for service accounts.

    summary

    Bulk update

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional bulkUpdateRequest: BulkUpdateRequest
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Create Lobby

  • createLobby(serviceId?: string, impersonatedUserId?: string, createRequest?: CreateRequest, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Create a new lobby and return the lobby metadata.

    summary

    Create a lobby

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional createRequest: CreateRequest
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Delete Lobby

  • deleteLobby(lobbyId: string, serviceId?: string, impersonatedUserId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<void>>
  • Delete a lobby so it's no longer discoverable/joinable.

    summary

    Delete a lobby

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<void>>

Get Hosted Lobbies

  • getHostedLobbies(serviceId?: string, impersonatedUserId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<string[]>>
  • Get a list of lobby IDs that are currently hosted by the player/service.

    summary

    Get a player/service's hosted lobbies

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<string[]>>

Get Joined Lobbies

  • getJoinedLobbies(serviceId?: string, impersonatedUserId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<string[]>>
  • Get a list of lobby IDs that the player is currently a member of.

    summary

    Get a player's joined lobbies

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<string[]>>

Get Lobby

  • getLobby(lobbyId: string, serviceId?: string, impersonatedUserId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Get the full details for a lobby including the game-specific metadata and player details.

    summary

    Get lobby details

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Heartbeat

  • heartbeat(lobbyId: string, serviceId?: string, impersonatedUserId?: string, body?: object, options?: AxiosRequestConfig): Promise<AxiosResponse<void>>
  • Heartbeat a lobby, updating its LastUpdated property, to signify that the lobby is not stale.

    summary

    Heartbeat a lobby

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional body: object
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<void>>

Join Lobby By Code

  • joinLobbyByCode(serviceId?: string, impersonatedUserId?: string, joinByCodeRequest?: JoinByCodeRequest, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Join an existing lobby using the lobby code if there is space available (i.e. total number of players is less than the value of MaxPlayers).

    summary

    Join a lobby with lobby code

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional joinByCodeRequest: JoinByCodeRequest
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Join Lobby By Id

  • joinLobbyById(lobbyId: string, serviceId?: string, impersonatedUserId?: string, player?: Player, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Join an existing lobby using the lobby ID if there is space available (i.e. total number of players is less than the value of MaxPlayers).

    summary

    Join a lobby with lobby ID

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional player: Player
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Query Lobbies

  • queryLobbies(serviceId?: string, impersonatedUserId?: string, queryRequest?: QueryRequest, options?: AxiosRequestConfig): Promise<AxiosResponse<QueryResponse>>
  • Query all of the public lobbies for a title and filter them down according to parameters provided by the client.

    summary

    Query public lobbies

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional queryRequest: QueryRequest
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<QueryResponse>>

Quick Join Lobby

  • quickJoinLobby(serviceId?: string, impersonatedUserId?: string, quickJoinRequest?: QuickJoinRequest, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Query all of the available lobbies for a title and filter them down according to parameters provided by the client. If possible, join one and return its information.

    summary

    Query available lobbies and join a random one

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional quickJoinRequest: QuickJoinRequest
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Reconnect

  • reconnect(lobbyId: string, serviceId?: string, impersonatedUserId?: string, body?: object, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Reconnect a disconnected player to a lobby using the lobby ID.

    summary

    Reconnect to a lobby after disconnecting

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional body: object
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Remove Player

  • removePlayer(lobbyId: string, playerId: string, serviceId?: string, impersonatedUserId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<void>>
  • Remove an individual player from a lobby. If the player being removed is the host, a random player is chosen as the new host. Hosts can avoid this by changing the hostId to another player using the Update Lobby API before leaving.

    summary

    Remove a player

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • playerId: string

      The ID of the player to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<void>>

Request Tokens

  • requestTokens(lobbyId: string, tokenRequest: TokenRequest[], serviceId?: string, impersonatedUserId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<{}>>
  • Request authentication tokens for use with other services that interact with Lobby.

    summary

    Authentication token request

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • tokenRequest: TokenRequest[]
    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<{}>>

Update Lobby

  • updateLobby(lobbyId: string, serviceId?: string, impersonatedUserId?: string, updateRequest?: UpdateRequest, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Update the properties of a lobby. This could include the lobby name, number of max players, the lobby's data property, etc.

    summary

    Update lobby data

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional updateRequest: UpdateRequest
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>

Update Player

  • updatePlayer(lobbyId: string, playerId: string, serviceId?: string, impersonatedUserId?: string, playerUpdateRequest?: PlayerUpdateRequest, options?: AxiosRequestConfig): Promise<AxiosResponse<Lobby>>
  • Update the properties of a player. Only the player matching the player ID can perform this action. This could include updating the data property for an individual player to include game-specific metadata. The index data property is not allowed on player data objects at this time.

    summary

    Update player data

    throws

    {RequiredError}

    memberof

    LobbyApi

    Parameters

    • lobbyId: string

      The ID of the lobby to execute the request against.

    • playerId: string

      The ID of the player to execute the request against.

    • Optional serviceId: string
    • Optional impersonatedUserId: string
    • Optional playerUpdateRequest: PlayerUpdateRequest
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<Lobby>>