lobby

package
v0.0.0-...-c857007 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package lobby handles players connecting to games and communication between games and players

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Debug is a flag that causes the lobby to log the types messages that are read
	Debug bool
	// Log is used to log errors and other information
	Log *log.Logger
	// MaxGames is the maximum number of games the lobby supports
	MaxGames int
	// MaxSockets is the maximum number of sockets the lobby supports
	MaxSockets int
	// GameCfg is used to create new games
	GameCfg controller.Config
	// SocketCfg is used to create new sockets
	SocketCfg socket.Config
}

Config contiains the properties to create a lobby

func (Config) NewLobby

func (cfg Config) NewLobby() (*Lobby, error)

NewLobby creates a new game lobby

type Lobby

type Lobby struct {
	// contains filtered or unexported fields
}

Lobby is the place users can create, join, and participate in games

func (*Lobby) AddUser

func (l *Lobby) AddUser(playerName game.PlayerName, w http.ResponseWriter, r *http.Request) error

AddUser adds a user to the lobby, it opens a new websocket (player) for the username

func (*Lobby) RemoveUser

func (l *Lobby) RemoveUser(playerName game.PlayerName)

RemoveUser removes the user from the lobby and a game, if any

func (*Lobby) Run

func (l *Lobby) Run(ctx context.Context)

Run runs the lobby until the context is closed.

Jump to

Keyboard shortcuts

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