session

package
v0.0.0-...-24c75d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(s *structs.Server, client *structs.Client)

Close terminates a client's session on the server. It handles the client leaving the lobby, notifying peers or transferring host responsibilities if the client is a host. If the client is a peer, it broadcasts a PEER_GONE message to other peers. If the client is a host, it examines lobby settings for host reclaim options and manages the lobby closure or host transfer process. Finally, it removes the client from the lobby and game, deletes the session, and closes client connections. Logs the closure of the session.

func LeaveAndDestroyLobby

func LeaveAndDestroyLobby(s *structs.Server, client *structs.Client, settings *structs.LobbySettings)

func LeaveLobbyWithAutomatedReclaim

func LeaveLobbyWithAutomatedReclaim(s *structs.Server, client *structs.Client, settings *structs.LobbySettings)

LeaveLobbyWithAutomatedReclaim handles the process of a client leaving a lobby with automated host reclaim. It first removes the current host, then checks for remaining peers in the lobby. If no peers remain, it checks if a server-side relay is used and deletes it if necessary, then destroys the lobby. If peers are present, it assigns the first peer in the list as the new host and broadcasts a HOST_RECLAIM message to inform all remaining peers of the new host. Finally, it ensures the client is removed from the lobby.

func LeaveLobbyWithPeerBasedReclaim

func LeaveLobbyWithPeerBasedReclaim(s *structs.Server, client *structs.Client, settings *structs.LobbySettings)

LeaveLobbyWithPeerBasedReclaim handles the process of a host leaving a lobby when peer-based reclaim is enabled. It first removes the current host from the lobby and checks the remaining peers. If no peers remain, it closes the lobby and deletes any server-side relays if necessary. If one peer remains, it reassigns the host role to that peer and informs them of the change. If multiple peers remain, it updates the lobby settings to indicate that a host reclaim is in progress and broadcasts a "RECLAIM_HOST" opcode to all peers. Finally, it removes the client from the lobby.

func Open

func Open(s *structs.Server, conn *websocket.Conn, gameid ulid.ULID) *structs.Client

Open creates a new client session on the server. It creates a temporary ULID for the peer, creates a new client struct with the provided websocket connection, and adds the client to the specified game and default lobby. It returns the newly created client struct.

func PrepareToChangeModesOrDisconnect

func PrepareToChangeModesOrDisconnect(s *structs.Server, client *structs.Client)

PrepareToChangeModesOrDisconnect handles a client leaving their current lobby and/or disconnecting from the server. If the client is a peer, it broadcasts a PEER_GONE message to other peers. If the client is a host, it examines lobby settings for host reclaim options and manages the lobby closure or host transfer process. Finally, it removes the client from the lobby and game, and clears the client's mode and lobby.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL