View Source Teiserver.Game.LobbyLib (Teiserver v0.0.4)
TODO: Library of lobby related functions.
Summary
Functions
Adds a client to the lobby
Adds a client to the lobby
Used to tell a lobby process the current match has started
Given a lobby_id it will close the lobby. Every client in the lobby will be removed from the lobby.
Used to cycle a lobby after a match has concluded.
Tests is the lobby name is acceptable. Can be over-ridden using the config fn_lobby_name_acceptor
Used to tell a lobby process the current match has started
Given a user_id of the host and the initial lobby name, starts a process for tracking the lobby.
Adds a client to the lobby
Subscribes the process to lobby updates for this user
Unsubscribes the process to lobby updates for this user
Functions
@spec add_client_to_lobby(Teiserver.user_id(), Teiserver.Game.Lobby.id()) :: :ok | {:error, String.t()}
Adds a client to the lobby
@spec can_add_client_to_lobby( Teiserver.user_id(), Teiserver.Game.Lobby.id(), String.t() ) :: {boolean(), String.t() | nil}
Adds a client to the lobby
@spec client_update_request(map(), Teiserver.Game.Lobby.id()) :: map()
Used to tell a lobby process the current match has started
Examples
iex> client_update_request(%{team_number: 1, id: 1}, 123)
%{}
iex> client_update_request(%{team_number: 1, id: 456}, 456)
nil
@spec close_lobby(Teiserver.Game.Lobby.id()) :: :ok
Given a lobby_id it will close the lobby. Every client in the lobby will be removed from the lobby.
Examples
iex> close_lobby(123) :ok
@spec cycle_lobby(Teiserver.Game.Lobby.id()) :: :ok
Used to cycle a lobby after a match has concluded.
Examples
iex> cycle_lobby(123)
:ok
iex> cycle_lobby(456)
nil
@spec get_lobby(Teiserver.Game.Lobby.id()) :: Teiserver.Game.Lobby.t() | nil
@spec get_lobby_attribute(Teiserver.Game.Lobby.id(), atom()) :: any()
@spec get_lobby_summary(Teiserver.Game.Lobby.id()) :: Teiserver.Game.LobbySummary.t() | nil
@spec list_lobby_ids() :: [Teiserver.Game.Lobby.id()]
@spec list_local_lobby_ids() :: [Teiserver.Game.Lobby.id()]
Tests is the lobby name is acceptable. Can be over-ridden using the config fn_lobby_name_acceptor
@spec lobby_start_match(Teiserver.Game.Lobby.id()) :: :ok
Used to tell a lobby process the current match has started
Examples
iex> lobby_start_match(123)
:ok
iex> lobby_start_match(456)
nil
@spec open_lobby(Teiserver.user_id(), Teiserver.Game.Lobby.name()) :: {:ok, Teiserver.Game.Lobby.id()} | {:error, String.t()}
Given a user_id of the host and the initial lobby name, starts a process for tracking the lobby.
It will then update the client of the host user and assign them to the lobby.
Examples
iex> open_lobby(123, "Name")
{:ok, 456}
iex> open_lobby(456, "Name")
{:error, "Client is not connected"}
@spec remove_client_from_lobby(Teiserver.user_id(), Teiserver.Game.Lobby.id()) :: :ok | nil
Adds a client to the lobby
@spec stream_lobby_summaries() :: Enumerable.t(Teiserver.Game.LobbySummary.t())
@spec stream_lobby_summaries(map()) :: Enumerable.t(Teiserver.Game.LobbySummary.t())
@spec subscribe_to_lobby(User.id() | User.t() | Client.t()) :: :ok
Subscribes the process to lobby updates for this user
@spec unsubscribe_from_lobby(User.id() | User.t() | Client.t()) :: :ok
Unsubscribes the process to lobby updates for this user
@spec update_lobby(Teiserver.Game.Lobby.id(), map()) :: :ok | nil