Documentation
¶
Index ¶
- func AddClientToGame(s *structs.Server, gameid string, client *structs.Client)
- func AddClientToLobby(s *structs.Server, lobbyid string, gameid string, client *structs.Client)
- func CreateSession(s *structs.Server, client *structs.Client) error
- func DeleteRelay(s *structs.Server, peer *structs.Client)
- func DeleteSession(s *structs.Server, client *structs.Client) error
- func DestroyLobby(s *structs.Server, gameid string, lobbyid string)
- func DoesGameExist(s *structs.Server, gameid string) bool
- func DoesLobbyExist(s *structs.Server, lobbyid string, gameid string) bool
- func DoesPeerExist(s *structs.Server, id string) bool
- func GetAllLobbies(s *structs.Server, gameid string) []string
- func GetByULID(s *structs.Server, id string) *structs.Client
- func GetGamePeers(s *structs.Server, gameid string) []*structs.Client
- func GetLobbyHost(s *structs.Server, lobbyid string, gameid string) (*structs.Client, error)
- func GetLobbyPeers(s *structs.Server, lobbyid string, gameid string) []*structs.Client
- func GetLobbySettings(s *structs.Server, lobbyid string, gameid string) *structs.LobbySettings
- func GetRelay(s *structs.Server, peer *structs.Client) *structs.Relay
- func GetRelayPeers(s *structs.Server, lobbyid string, gameid string) []*structs.Relay
- func GetSession(s *structs.Server, id string) *structs.Session
- func IsClientInGame(s *structs.Server, gameid string, client *structs.Client) bool
- func IsClientInLobby(s *structs.Server, lobbyid string, gameid string, client *structs.Client) bool
- func RemoveClientFromGame(s *structs.Server, gameid string, client *structs.Client)
- func RemoveClientFromLobby(s *structs.Server, lobbyid string, gameid string, client *structs.Client)
- func RemoveLobbyHost(s *structs.Server, lobbyid string, gameid string, client *structs.Client)
- func SetLobbyHost(s *structs.Server, lobbyid string, gameid string, client *structs.Client)
- func SetLobbySettings(s *structs.Server, lobbyid string, gameid string, ...)
- func SetRelay(s *structs.Server, peer *structs.Client, relay *structs.Relay)
- func VerifyRelayState(r *structs.Relay, packet *structs.RelayPacket) error
- func WithoutPeer(clients []*structs.Client, client *structs.Client) []*structs.Client
- func WithoutRelay(relays []*structs.Relay, relay *structs.Relay) []*structs.Relay
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClientToGame ¶
AddClientToGame adds the given client to the game with the given ID. If the game does not exist, it is created. The client is appended to the game's client slice. The function is thread-safe.
func AddClientToLobby ¶
AddClientToLobby adds a client to a lobby in a game on a server, or creates the lobby if it doesn't exist. It does nothing if the client is already in the lobby.
func CreateSession ¶
CreateSession creates a new session for the given client on the server. It returns an error if a session for the client already exists. The function is thread-safe.
func DeleteRelay ¶
DeleteRelay gracefully shuts down a relay peer and then deletes it from the server. This function is thread-safe and can be called from any goroutine.
func DeleteSession ¶
DeleteSession deletes a session associated with the given client from the server. It returns an error if the session does not exist. The function is thread-safe.
func DestroyLobby ¶
DestroyLobby destroys a lobby in a game on a server, removing it from the server's Games map. It does nothing if the lobby doesn't exist. It locks the server's Games map and the specific game's Lobbies map for thread safety.
func DoesGameExist ¶
DoesGameExist checks if a game with the given ID exists on the server. It returns true if the game exists, otherwise false.
func DoesLobbyExist ¶
DoesLobbyExist checks if a lobby with the given lobbyid exists in a game with the given gameid on the server. It returns true if the lobby exists, otherwise false. The function acquires a read lock on the server's Games map for thread safety while performing the existence checks.
func DoesPeerExist ¶
DoesPeerExist checks if a peer session with the given ID exists on the server. It returns true if the session exists, otherwise false.
func GetAllLobbies ¶
GetAllLobbies retrieves all lobbies for a given game, excluding the default lobby entry.
func GetByULID ¶
GetByULID returns the client associated with the given ULID, or an error if no such client exists.
func GetGamePeers ¶
GetGamePeers returns a slice of all clients in the specified game. The function will panic if the game does not exist. The function is thread-safe.
func GetLobbyHost ¶
GetLobbyHost retrieves the host client of a specified lobby in a given game on the server. It returns a pointer to the host client if the lobby exists, or an error if the lobby does not exist. The function locks the server's Games map and the specific lobby's Mutex for thread safety.
func GetLobbyPeers ¶
GetLobbyPeers retrieves all clients in a given lobby in a given game on a server. It returns a slice of client pointers if the game and lobby exist, an empty slice otherwise.
func GetLobbySettings ¶
GetLobbySettings retrieves the settings for a specified lobby in a given game on the server. It returns a pointer to the LobbySettings if the lobby exists, or nil if the lobby does not exist. The function locks the server's Games map and the specific lobby's Mutex for thread safety.
func GetRelay ¶
GetRelay gets a relay peer from the server. The returned relay is guaranteed to still exist for the duration of the RLock.
func GetRelayPeers ¶
func GetSession ¶
GetSession retrieves the session associated with the given ID from the server. It returns a pointer to the structs.Session if the session exists, or nil if the session does not exist. The function is thread-safe.
func IsClientInGame ¶
IsClientInGame checks if a client is in the specified game on the server. It will panic if the game does not exist. The function is thread-safe.
func IsClientInLobby ¶
IsClientInLobby checks if a given client is in a given lobby in a given game on a server. It returns true if the client is in the lobby, false otherwise.
func RemoveClientFromGame ¶
RemoveClientFromGame removes a client from the specified game on the server. If the game does not exist, the function will panic. The function locks the game's client slice for thread safety while ensuring the client is present before attempting removal.
func RemoveClientFromLobby ¶
func RemoveClientFromLobby(s *structs.Server, lobbyid string, gameid string, client *structs.Client)
RemoveClientFromLobby removes a client from a lobby in a game on a server, if it exists. It does nothing if the client is not in the lobby or if the lobby doesn't exist. It also does nothing if the client doesn't exist on the server.
func RemoveLobbyHost ¶
RemoveLobbyHost removes the host of a lobby in a game on a server. It does nothing if the lobby doesn't exist. It locks the server's Games map and the specific game's Lobbies map for thread safety.
func SetLobbyHost ¶
SetLobbyHost sets the host of a lobby in a game on a server. It does nothing if the lobby doesn't exist. It locks the server's Games map and the specific game's Lobbies map for thread safety.
func SetLobbySettings ¶
func SetLobbySettings(s *structs.Server, lobbyid string, gameid string, settings *structs.LobbySettings)
SetLobbySettings sets the settings of a lobby in a game on a server. It panics if the lobby doesn't exist. It locks the server's Games map and the specific lobby's Mutex for thread safety.
func SetRelay ¶
SetRelay sets a relay peer for the given peer on the server. The function is thread-safe and can be called from any goroutine. The relay is guaranteed to exist for the duration of the Lock.
func VerifyRelayState ¶
func VerifyRelayState(r *structs.Relay, packet *structs.RelayPacket) error
VerifyRelayState checks the validity of a relay packet's state. It ensures that the recipient field is set and that the recipient exists as a peer on the server. It then verifies whether the recipient peer can be retrieved using its ULID and is part of the same lobby as the relay. Returns an error if any of these validations fail.
func WithoutPeer ¶
WithoutPeer returns a slice of all elements in the given slice of clients that are not equal to the given client. Nil elements are also ignored. The returned slice is a new slice and does not modify the original slice in any way.
func WithoutRelay ¶
WithoutRelay returns a slice of all elements in the given slice of relays that are not equal to the given relay. Nil elements are also ignored. The returned slice is a new slice and does not modify the original slice in any way.
Types ¶
This section is empty.