GodotMattohaLobbySystem 0.2.4
Loading...
Searching...
No Matches
Mattoha.Nodes.MattohaServer Class Reference

Public Member Functions

delegate void PlayerJoinedLobbyEventHandler (long playerId, int lobbyId)
 Emmited when a player join a lobby.
 
delegate void PlayerLeftLobbyEventHandler (long playerId, int lobbyId)
 Emmited when a player leave a lobby.
 
delegate void LobbyGameStartedEventHandler (int lobbyId)
 Emmited when a lobby game started.
 
delegate void LobbyGameEndedEventHandler (int lobbyId)
 Emmited when a lobby game ended.
 
delegate void LobbyRemovedEventHandler (int lobbyId)
 Emmited when a lobby has been removed.
 
override void _Ready ()
 
Dictionary< string, Variant > FindSpawnedNode (Dictionary< string, Variant > payload)
 Given a spawn payload, find the node in spawned nodes.
 
Dictionary< string, Variant > FindRemovedSceneNode (Dictionary< string, Variant > payload)
 Given a despawn payload, find the removed scene node in RemovedSceneNodes.
 
Dictionary< string, Variant > GetPlayer (long playerId)
 Get player by it's ID.
 
Dictionary< string, Variant > GetPlayerLobby (long playerId)
 Get lobby that player is joined to by player ID.
 
Array< Dictionary< string, Variant > > GetLobbyPlayers (int lobbyId)
 Get list of players that joined to a given lobby.
 
Array< Dictionary< string, Variant > > GetLobbyPlayersSecured (int lobbyId)
 Get list of players that joined to a given lobby but secure the dictionaries, meanining that any propert inside "PrivateProps" will be hidden.
 
void SendRpcForPlayersInLobby (int lobbyId, string methodName, Dictionary< string, Variant > payload, bool secureDict=false, long superPeer=0, long ignorePeer=0)
 Send an RPC from server to all players in a given lobby.
 
void RefreshAvailableLobbiesForAll (bool force=false)
 Refresh all available lobbies for all peers if "AutoLoadAvailableLobbies" is enabled or "force" argument is true.
 
void LoadLobbyPlayersForAll (int lobbyId)
 Refresh joined players list for all joined players in a given lobbyId.
 
void SpawnNode (Dictionary< string, Variant > payload, int lobbyId)
 Spawn node from server for all joined players in same lobby.
 
void DespawnNode (Dictionary< string, Variant > payload)
 Despawn node from server by passing a payload generated by method "GenerateNodePayloadData()".
 
void RemovePlayerFromLobby (long playerId)
 Remove player from joiend lobby, this will emmit "LeaveLobby" for player removed, "SetPlayerData" for player removed, "PlayerLeft" and "LoadLobbyPlayersSucceed" for joined players, "LoadAvailableLobbiesSucceed" for all online players if "AutoLoadAvailableLobbies" is enabled, in addition to sync data for players.
 

Properties

MattohaServerMiddleware MiddlewareNode [get, set]
 Server Middleware for executing logic before and after almost every event that client do, This node should have "MattohaMiddleware" or an inherited class node script attached to it.
 
Dictionary< long, Dictionary< string, Variant > > Players = new() [get]
 Registered players dictionary, where the key is the id of player.
 
Dictionary< int, Dictionary< string, Variant > > Lobbies = new() [get]
 Created lobbies by users, a dictionary where the key is the id of lobby.
 
Dictionary< int, Array< Dictionary< string, Variant > > > SpawnedNodes = new() [get]
 A dictionary that contains spawned nodes for each lobby, where the key is the lobby id.
 
Dictionary< int, Array< Dictionary< string, Variant > > > RemovedSceneNodes = new() [get]
 A dictionary that contains removed scene nodes that has been despawned during game play for each lobby, where the key is the lobby id.
 
Node GameHolder [get]
 The game holder node that contains lobbies nodes and game plays.
 

Member Function Documentation

◆ DespawnNode()

void Mattoha.Nodes.MattohaServer.DespawnNode ( Dictionary< string, Variant > payload)

Despawn node from server by passing a payload generated by method "GenerateNodePayloadData()".

Parameters
payload

◆ FindRemovedSceneNode()

Dictionary< string, Variant > Mattoha.Nodes.MattohaServer.FindRemovedSceneNode ( Dictionary< string, Variant > payload)

Given a despawn payload, find the removed scene node in RemovedSceneNodes.

Parameters
payloadgenerated payload from "GenerateNodePayloadData" method.
Returns
null if not found.

◆ FindSpawnedNode()

Dictionary< string, Variant > Mattoha.Nodes.MattohaServer.FindSpawnedNode ( Dictionary< string, Variant > payload)

Given a spawn payload, find the node in spawned nodes.

Parameters
payloadGenerated payload from "GenerateNodePayloadData" method.
Returns
null if not found.

◆ GetLobbyPlayers()

Array< Dictionary< string, Variant > > Mattoha.Nodes.MattohaServer.GetLobbyPlayers ( int lobbyId)

Get list of players that joined to a given lobby.

Parameters
lobbyId
Returns
Empty array if no players in lobby.

◆ GetLobbyPlayersSecured()

Array< Dictionary< string, Variant > > Mattoha.Nodes.MattohaServer.GetLobbyPlayersSecured ( int lobbyId)

Get list of players that joined to a given lobby but secure the dictionaries, meanining that any propert inside "PrivateProps" will be hidden.

Parameters
lobbyId
Returns
Empty array if no players in lobby.

◆ GetPlayer()

Dictionary< string, Variant > Mattoha.Nodes.MattohaServer.GetPlayer ( long playerId)

Get player by it's ID.

Parameters
playerId
Returns
null if not found.

◆ GetPlayerLobby()

Dictionary< string, Variant > Mattoha.Nodes.MattohaServer.GetPlayerLobby ( long playerId)

Get lobby that player is joined to by player ID.

Parameters
playerId
Returns
null if not found.

◆ LoadLobbyPlayersForAll()

void Mattoha.Nodes.MattohaServer.LoadLobbyPlayersForAll ( int lobbyId)

Refresh joined players list for all joined players in a given lobbyId.

Parameters
lobbyId

◆ RefreshAvailableLobbiesForAll()

void Mattoha.Nodes.MattohaServer.RefreshAvailableLobbiesForAll ( bool force = false)

Refresh all available lobbies for all peers if "AutoLoadAvailableLobbies" is enabled or "force" argument is true.

Parameters
forceif true, then ignore the value of "AutoLoadAvailablelobbies" and force to load available lobbies for all connected players.

◆ RemovePlayerFromLobby()

void Mattoha.Nodes.MattohaServer.RemovePlayerFromLobby ( long playerId)

Remove player from joiend lobby, this will emmit "LeaveLobby" for player removed, "SetPlayerData" for player removed, "PlayerLeft" and "LoadLobbyPlayersSucceed" for joined players, "LoadAvailableLobbiesSucceed" for all online players if "AutoLoadAvailableLobbies" is enabled, in addition to sync data for players.

Parameters
playerId

◆ SendRpcForPlayersInLobby()

void Mattoha.Nodes.MattohaServer.SendRpcForPlayersInLobby ( int lobbyId,
string methodName,
Dictionary< string, Variant > payload,
bool secureDict = false,
long superPeer = 0,
long ignorePeer = 0 )

Send an RPC from server to all players in a given lobby.

Parameters
lobbyIdThe lobbyId to send the RPC for it's players.
methodNameRPC method name.
payloadpayload to send "Dictionary"
secureDictif true, "MattohaUtils.ToSecuredDict()" will be applied on payload.
superPeerthis peer id will recieve the original payload without secure it.
ignorePeerignore this peer and dont send RPC for him, usefull if you want to ignore the sender.

◆ SpawnNode()

void Mattoha.Nodes.MattohaServer.SpawnNode ( Dictionary< string, Variant > payload,
int lobbyId )

Spawn node from server for all joined players in same lobby.

Parameters
payloada spawn payload generated from "GenerateNodePayloadData"
lobbyIdlobby id