NetworkedMultiplayerGodotcord
A multiplayer peer that uses the Discord Network
Description
A multiplayer peer that uses the Discord Network.
There are multiple id’s connected with multiplayer. The first on is the peer id.
It is used to identify a user in a lobby. It can however not be used to retrieve other data of a user (e.g. profile picture).
The peer id will be set as the sender if of rcp calls.
The other one is the user id. It can be used to retrieve additional information about a user.
You can convert from one to the other using get_user_id_by_peer
and get_peer_id_by_user
void | create_lobby(max_users : int, public : boolean = false) |
void | join_lobby(lobby_id : int, secret : string) |
void | join_lobby_activity(activity_secret : string) |
void | close_connection() |
void | disconnect_peer(id : int) |
int | get_lobby_id() |
string | get_lobby_secret() |
string | get_lobby_activity_secret() |
int | get_current_members() |
int | get_max_members() |
void | set_public(public : boolean) |
void | set_size(size : int) |
void | set_metadata(key : string, value : string) |
string | get_metadata(key : string) |
Array | get_connected_peers() |
void | get_user_id_by_peer(peer_id : int) |
void | get_peer_id_by_user(user_id : int) |
Signals
- created_lobby()
Emitted when a new lobby has been creates successfully.
Method Descriptions
Creates a new lobby with max_users
slots.
The creator will automatically set as the owner and joins the lobby himself.
...public
Joins the lobby with the id lobby_id
using the id and secret.
Joins the lobby encoded in activity_secret
Disconnect from the current lobby. Should only be called when the user is currently in a lobby.
Removes the user with the id id
from the lobby.
Will only be executed when the local user is the owner of the lobby.
Returns the lobby id of the current lobby. Prints an error if the instance is not connected to a lobby.
Returns the lobby secret of the current lobby. Prints an error if the instance is not connected to a lobby.
Returns the activity secret of the current lobby. Prints an error if the instance is not connected to a lobby.
Returns the number of currently connected users. Prints an error if the instance is not connected to a lobby.
Returns the capacity of the lobby. Prints an error if the instance is not connected to a lobby.
Can only be run as the lobby owner. Sets the key/value pair as metadata of the current lobby . Overwrites the value if the key already exists(?).
Returns the value associated with the key.
Returns an array with all connected users
Returns the user id associated with peer_id
.
Returns the peer id associated with user_id
.