Skip to content

MultiplayerPeer

Only available in the GodotSteam MultiplayerPeer repo

Functions

add_peer

add_peer( uint64_t steam_id, int virtual_port = 0 )

Parameter Type Notes
steam_id uint64_t The Steam ID of the player to add as a peer.
virtual_port int Expected to be 0; only helpful if you want to have multiple connections between two users. Defaults to 0.

Creates a connection with a new peer. Runs connectP2P under the hood.

Returns: Error enum

Returns OK upon success; otherwise, ERR_CANT_CREATE if the underlying P2P connection fails.

connect_to_lobby

connect_to_lobby( uint64_t lobby_id )

Parameter Type Notes
lobby_id uint64_t The Steam lobby ID to connect to.

Checks you are in the lobby by calling getLobbyOwner or prints an error ERR_CANT_CREATE.

It then calls create_client for the host or prints an Error enum if there is no host found.

Finally it connects to the rest of the members of the lobby, calling add_peer for each.

Returns: Error enum

Returns OK upon success; otherwise, ERR_ALREADY_IN_USE if connection_status is not CONNECTION_DISCONNECTED.

create_client

create_client( uint64_t steam_id, int virtual_port = 0 )

Parameter Type Notes
steam_id uint64_t The Steam ID of the host we're connecting to.
virtual_port int Expected to be 0; only helpful if you want to have multiple connections between two users. Defaults to 0.

On success, this sets server to false and unique_id to a newly generated unique ID.

It then creates a listen socket with createListenSocketP2P and a poll group with createPollGroup under-the-hood.

It then calls add_peer with the host steam_id and virtual_port.

Finally it sets set_refuse_new_connections to false and connection_status to CONNECTION_CONNECTING.

Returns: Error enum

Returns OK upon success; otherwise, ERR_ALREADY_IN_USE if connection_status is not CONNECTION_DISCONNECTED.

create_host

create_host( int virtual_port = 0 )

Parameter Type Notes
virtual_port int Expected to be 0; only helpful if you want to have multiple connections between two users. Defaults to 0.

On success, this sets server to true and unique_id to 1.

It then creates a listen socket with createListenSocketP2P and a poll group with createPollGroup under-the-hood.

Finally it sets set_refuse_new_connections to false and connection_status to CONNECTION_CONNECTED.

Returns: Error enum

Returns OK upon success; otherwise, ERR_ALREADY_IN_USE if connection_status is not CONNECTION_DISCONNECTED.

get_debug_level

get_debug_level( )

Returns the internal debug_level property value.

Returns: DebugLevel enum

get_no_delay

get_no_delay( )

Returns the internal no_delay property value.

Returns: bool

get_no_nagle

get_no_nagle( )

Returns the internal no_nagle property value.

Returns: bool

get_peer

get_peer( int peer_id )

Parameter Type Notes
peer_id int The ID of the packet peer to retrieve.

Returns: SteamPacketPeer

Returns a SteamPacketPeer RefCounted object on success; otherwise, null.

get_peer_id_for_steam_id

get_peer_id_for_steam_id( uint64_t steam_id )

Parameter Type Notes
steam_id uint64_t The Steam ID to get the peer ID from.

Returns the peer ID for the given Steam ID; if it exists.

Returns: int

Returns the peer ID on success or the unique_id if passing the local user's Steam ID; otherwise, 0.

get_steam_id_for_peer_id

get_steam_id_for_peer_id( int peer_id )

Parameter Type Notes
peer_id int The peer ID to get the Steam ID from.

Returns the Steam ID for the given peer ID; if it exists.

Returns: uint64_t

Returns the Steam ID on success or the local user's Steam ID if passing the unique_id; otherwise, 0.

host_with_lobby

host_with_lobby( uint64_t lobby_id )

Parameter Type Notes
lobby_id uint64_t The lobby ID we are hosting.

You must have created a lobby with createLobby prior to calling this. If you use a lobby_id you are not the owner of, this will error with ERR_CANT_CREATE.

Sets tracked_lobby to this lobby on success.

It then calls create_host and add_peer for all lobby members.

Returns: Error enum

Returns OK upon success; otherwise, ERR_ALREADY_IN_USE if connection_status is not CONNECTION_DISCONNECTED.

set_debug_level

set_debug_level( DebugLevel debug_level )

Parameter Type Notes
debug_level DebugLevel enum The debug level to set.

Sets the debug_level property internally.

Returns: void

set_no_delay

set_no_delay( bool no_delay )

Parameter Type Notes
no_delay bool Whether or not to use NETWORKING_SEND_NO_DELAY flag.

Sets the no_delay property internally.

Returns: void

set_no_nagle

set_no_nagle( bool no_nagle )

Parameter Type Notes
no_nagle bool Whether or not to use NETWORKING_SEND_NO_NAGLE flag.

Sets the no_nagle property internally.

Returns: void

Properties

Name Variant Set Get
debug_level int set_debug_level get_debug_level
no_delay bool set_no_delay get_no_delay
no_nagle bool set_no_nagle get_no_nagle

Enums

DebugLevel

Enumerator SDK Name Value Details
DEBUG_LEVEL_NONE - 0 -
DEBUG_LEVEL_PEER - 1 -
DEBUG_LEVEL_STEAM - 2 -