res://addons/w4gd/matchmaker/matchmaker.gd

Inherits: Node

Interacts with the W4 Cloud matchmaker component.

Methods

res://addons/w4gd/rest-client/client_request.gd

create_lobby ( LobbyType p_type, Dictionary p_opts, bool p_subscribe )

res://addons/w4gd/rest-client/client_request.gd

find_lobbies ( Dictionary p_query )

res://addons/w4gd/rest-client/client_request.gd

get_cluster_list ( )

res://addons/w4gd/rest-client/client_request.gd

get_lobby ( String p_lobby_id, bool p_subscribe )

res://addons/w4gd/rest-client/client_request.gd

join_lobby ( String p_lobby_id, bool p_subscribe )

res://addons/w4gd/rest-client/client_request.gd

join_matchmaker_queue ( Dictionary p_props, bool p_auto_leave )

res://addons/w4gd/rest-client/client_request.gd

leave_matchmaker_queue ( res://addons/w4gd/matchmaker/matchmaker.gd:MatchmakerTicket p_matchmaker_ticket )

void

set_webrtc_ice_servers ( Array p_ice_servers )


Enumerations

enum LobbyType:

LobbyType LOBBY_ONLY = 0

LobbyType DEDICATED_SERVER = 1

LobbyType WEBRTC = 2


enum LobbyState:

LobbyState NEW = 1

LobbyState IN_PROGRESS = 2

LobbyState SEALED = 3

LobbyState DONE = 4


Constants

DEFAULT_WEBRTC_ICE_SERVERS = [{ "urls": ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302", "stun:stun2.l.google.com:19302", "stun:stun3.l.google.com:19302", "stun:stun4.l.google.com:19302"] }]

The default WebRTC ICE servers, if none are provided.


Method Descriptions

res://addons/w4gd/rest-client/client_request.gd create_lobby ( LobbyType p_type, Dictionary p_opts, bool p_subscribe )

Creates a request to create a new lobby. A res://addons/w4gd/matchmaker/matchmaker.gd:Lobby will be returned as the data. p_opts can contain the following keys: - props: A Dictionary of lobby properties to be used as needed by your game. - max_players: The maximum number of players allowed in the lobby (the default is 2). - initial_players: An Array of player UUIDs to add to automatically join to the lobby. - cluster: The name of the cluster to allocate the dedicated server when using a dedicated server lobby.


res://addons/w4gd/rest-client/client_request.gd find_lobbies ( Dictionary p_query )

Creates a request to find lobbies that the current player has access to. This can be useful after restarting the game to see if we can reconnect to an existing match. p_query is a Dictionary that takes the following keys: - only_my_lobbies (bool): If set to true, this will only list lobbies that the current user has joined. - include_player_count (bool): If set to true, this will include player_count in the result. - constraints (Dictionary): A Dictionary of constraints that lobbies must match. Returns an array of Dictionary's with the following keys: - id - type - state - creator_id - props - cluster - created_at Usage:

var result = await W4GD.matchmaker.find_lobbies({
    # Includes a `player_count` for each lobby in the result.
    include_player_count = true,
    # Filters to only include lobbies the current user is a member of (as opposed to all lobbies they have access to).
    only_my_lobbies = true,
    # Arbitrary constraints on the lobby's columns and properties.
    constraints = {
        'type': W4GD.matchmaker.LobbyType.DEDICATED_SERVER,
        'state': [W4GD.matchmaker.LobbyState.NEW, W4GD.matchmaker.LobbyState.IN_PROGRESS],
        'player_count': {
            op = '<',
            value = 5,
        },
        # This is a top-level element inside the JSON of the 'props' column.
        'props.game-mode': 'battle-royale',
    },
}).async()

res://addons/w4gd/rest-client/client_request.gd get_cluster_list ( )

Gets a list of valid dedicated server cluster names.


res://addons/w4gd/rest-client/client_request.gd get_lobby ( String p_lobby_id, bool p_subscribe )

Creates a request to get a lobby. A res://addons/w4gd/matchmaker/matchmaker.gd:Lobby will be returned as the data.


res://addons/w4gd/rest-client/client_request.gd join_lobby ( String p_lobby_id, bool p_subscribe )

Creates a request to join a lobby. A res://addons/w4gd/matchmaker/matchmaker.gd:Lobby will be returned as the data.


res://addons/w4gd/rest-client/client_request.gd join_matchmaker_queue ( Dictionary p_props, bool p_auto_leave )

Creates a request to join the matchmaker queue. A res://addons/w4gd/matchmaker/matchmaker.gd:MatchmakerTicket will be returned as the data.


res://addons/w4gd/rest-client/client_request.gd leave_matchmaker_queue ( res://addons/w4gd/matchmaker/matchmaker.gd:MatchmakerTicket p_matchmaker_ticket )

Creates a request to leave the matchmaker queue.


void set_webrtc_ice_servers ( Array p_ice_servers )

Sets the list of WebRTC ICE servers.