lobby

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package lobby contains code to view available games and to close the websocket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DOM added in v1.2.0

type DOM interface {
	QuerySelector(query string) js.Value
	FormatTime(utcSeconds int64) string
	CloneElement(query string) js.Value
	RegisterFuncs(ctx context.Context, wg *sync.WaitGroup, parentName string, jsFuncs map[string]js.Func)
	NewJsFunc(fn func()) js.Func
	NewJsEventFuncAsync(fn func(event js.Value), async bool) js.Func
}

DOM interacts with the page.

type Game added in v1.2.0

type Game interface {
	Leave()
}

Game is held so the lobby can notify of it when the user leaves.

type Lobby

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

Lobby handles viewing, joining, and creating games on the server.

func New

func New(dom DOM, log Log, game Game) *Lobby

New creates a lobby for games.

func (*Lobby) InitDom

func (l *Lobby) InitDom(ctx context.Context, wg *sync.WaitGroup)

InitDom registers lobby dom functions.

func (*Lobby) SetGameInfos

func (l *Lobby) SetGameInfos(gameInfos []game.Info, username string)

SetGameInfos updates the game-infos table with the game infos for the username.

type Log added in v1.2.0

type Log interface {
	Error(text string)
}

Log is used to store text about connection errors.

type Socket

type Socket interface {
	Connect(event js.Value) error
	Close()
}

Socket is a structure that connects the server to the lobby.

Jump to

Keyboard shortcuts

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