This document provides a detailed reference for the public properties and methods of the PlayFlowLobbyManagerV2 class.

Properties

Instance
PlayFlowLobbyManagerV2
required
Singleton instance of the Lobby Manager. Access all lobby functionality through this.
IsReady
bool
required
Returns true if the manager has been successfully initialized.
CurrentLobby
Lobby
required
Gets the full data for the lobby the player is currently in. Returns null if not in a lobby.
PlayerId
string
required
Gets the unique ID of the current player, as provided during initialization.
State
LobbyState
required
Gets the current state of the lobby session (e.g., Disconnected, InLobby).
Events
PlayFlowEvents
required
Provides access to all lobby-related UnityEvents (e.g., OnLobbyJoined, OnPlayerLeft).
AvailableLobbies
List<Lobby>
required
A cached list of all currently available public lobbies. This list is updated automatically if auto-refresh is enabled.
IsInLobby
bool
required
A quick check to see if the player is currently in a lobby.
IsHost
bool
required
Returns true if the current player is the host of the lobby they are in.
InviteCode
string
required
Gets the invite code for the current private lobby. Returns null if not in a private lobby.

Methods

Initializes the lobby manager. This must be called before any other lobby operations.
public void Initialize(string playerId, Action onComplete = null)
playerId
string
required
A unique identifier for the local player.
onComplete
Action
An optional callback that is invoked when initialization is successful.
Creates a new lobby. There are two overloads for this method.Simple:
public void CreateLobby(string name, int maxPlayers = 4, bool isPrivate = false, Action<Lobby> onSuccess = null, Action<string> onError = null)
name
string
required
The public name of the lobby.
maxPlayers
int
The maximum number of players.
isPrivate
bool
If true, the lobby will not appear in public searches.
onSuccess
Action<Lobby>
Callback invoked with the created lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Detailed:
public void CreateLobby(string name, int maxPlayers, bool isPrivate, bool allowLateJoin, string region, Dictionary<string, object> customSettings, Action<Lobby> onSuccess = null, Action<string> onError = null)
name
string
required
The public name of the lobby.
maxPlayers
int
required
The maximum number of players that can join.
isPrivate
bool
required
If true, the lobby will not appear in public searches.
allowLateJoin
bool
required
If true, players can join even after the match has started.
region
string
required
The server region for the lobby (e.g., “us-west”).
customSettings
Dictionary<string, object>
required
A dictionary of custom game-specific settings.
onSuccess
Action<Lobby>
Callback invoked with the created lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Joins an existing lobby using its unique ID.
public void JoinLobby(string lobbyId, Action<Lobby> onSuccess = null, Action<string> onError = null)
lobbyId
string
required
The unique ID (UUID) of the lobby to join.
onSuccess
Action<Lobby>
Callback invoked with the joined lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Joins an existing private lobby using its invite code.
public void JoinLobbyByCode(string inviteCode, Action<Lobby> onSuccess = null, Action<string> onError = null)
inviteCode
string
required
The invite code of the lobby to join.
onSuccess
Action<Lobby>
Callback invoked with the joined lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Leaves the lobby the player is currently in.
public void LeaveLobby(Action onSuccess = null, Action<string> onError = null)
onSuccess
Action
Callback invoked on successfully leaving the lobby.
onError
Action<string>
Callback invoked with an error message on failure.
Updates the local player’s custom state data within the lobby. This is useful for synchronizing data like character selection or ready status.
public void UpdatePlayerState(Dictionary<string, object> state, Action<Lobby> onSuccess = null, Action<string> onError = null)
state
Dictionary<string, object>
required
A dictionary representing the player’s custom data.
onSuccess
Action<Lobby>
Callback invoked with the updated lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Updates another player’s custom state data within the lobby. This is a host-only action, useful for things like assigning teams or roles.
public void UpdateStateForPlayer(string targetPlayerId, Dictionary<string, object> state, Action<Lobby> onSuccess = null, Action<string> onError = null)
targetPlayerId
string
required
The unique ID of the player whose state you want to update.
state
Dictionary<string, object>
required
A dictionary representing the new data for the target player.
onSuccess
Action<Lobby>
Callback invoked with the updated lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Kicks a player from the lobby. This can only be called by the host.
public void KickPlayer(string playerToKickId, Action<Lobby> onSuccess = null, Action<string> onError = null)
playerToKickId
string
required
The unique ID of the player to remove from the lobby.
onSuccess
Action<Lobby>
Callback invoked with the updated lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Transfers host privileges to another player in the lobby. This can only be called by the current host.
public void TransferHost(string newHostId, Action<Lobby> onSuccess = null, Action<string> onError = null)
newHostId
string
required
The unique ID of the player who will become the new host.
onSuccess
Action<Lobby>
Callback invoked with the updated lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Starts the match. This can only be called by the lobby host. Changes the lobby status to “in_game”.
public void StartMatch(Action<Lobby> onSuccess = null, Action<string> onError = null)
onSuccess
Action<Lobby>
Callback invoked with the updated lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Ends the match. This can only be called by the lobby host. Changes the lobby status back to “waiting”.
public void EndMatch(Action<Lobby> onSuccess = null, Action<string> onError = null)
onSuccess
Action<Lobby>
Callback invoked with the updated lobby data on success.
onError
Action<string>
Callback invoked with an error message on failure.
Gets the connection details (IP and Port) for the game server if the lobby is in an active match.
public ConnectionInfo? GetGameServerConnectionInfo()
Returns: A ConnectionInfo struct if the server is running, otherwise null.