View Source Teiserver.Game.LobbyLib (Teiserver v0.0.4)

TODO: Library of lobby related functions.

Summary

Functions

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

Link to this function

add_client_to_lobby(user_id, lobby_id)

View Source
@spec add_client_to_lobby(Teiserver.user_id(), Teiserver.Game.Lobby.id()) ::
  :ok | {:error, String.t()}

Adds a client to the lobby

Link to this function

can_add_client_to_lobby(user_id, lobby_id, password \\ nil)

View Source
@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

Link to this function

client_update_request(changes, lobby_id)

View Source
@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
Link to this function

default_lobby_name_acceptable?(name)

View Source
@spec default_lobby_name_acceptable?(String.t()) :: boolean()
@spec get_lobby(Teiserver.Game.Lobby.id()) :: Teiserver.Game.Lobby.t() | nil
Link to this function

get_lobby_attribute(lobby_id, key)

View Source
@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()]
Link to this function

lobby_name_acceptable?(name)

View Source
@spec lobby_name_acceptable?(String.t()) :: boolean()

Tests is the lobby name is acceptable. Can be over-ridden using the config fn_lobby_name_acceptor

Link to this function

lobby_start_match(lobby_id)

View Source
@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
Link to this function

open_lobby(host_id, name)

View Source
@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"}
Link to this function

remove_client_from_lobby(user_id, lobby_id)

View Source
@spec remove_client_from_lobby(Teiserver.user_id(), Teiserver.Game.Lobby.id()) ::
  :ok | nil

Adds a client to the lobby

Link to this function

stream_lobby_summaries()

View Source
@spec stream_lobby_summaries() :: Enumerable.t(Teiserver.Game.LobbySummary.t())
Link to this function

stream_lobby_summaries(filters)

View Source
@spec stream_lobby_summaries(map()) :: Enumerable.t(Teiserver.Game.LobbySummary.t())
Link to this function

subscribe_to_lobby(lobby_or_lobby_id)

View Source
@spec subscribe_to_lobby(User.id() | User.t() | Client.t()) :: :ok

Subscribes the process to lobby updates for this user

Link to this function

unsubscribe_from_lobby(lobby_or_lobby_id)

View Source
@spec unsubscribe_from_lobby(User.id() | User.t() | Client.t()) :: :ok

Unsubscribes the process to lobby updates for this user

Link to this function

update_lobby(lobby_id, data)

View Source
@spec update_lobby(Teiserver.Game.Lobby.id(), map()) :: :ok | nil