mechdevoir

package
v0.0.0-...-a3e6692 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mechdevoir collects certain high level UI commands from clients and distributes some associated world state affected by these commands.

The semantic meaning of these UI commands is already standardised and known before they are sent to the server. Examples include pause, play, and shutdown. The UI elements for these commands will normally be visually distinct from a Mechane world's own UI elements, for example this may be accomplished by locating them on an exclusive sidebar.

UI events such as keyboard key events, mouse move events, and ShutterbugPixels' overlayer clicks are dealt with by a different package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDevoirHandleFunc

func NewDevoirHandleFunc(
	dvr *Devoir,
	shutterbugs mechshutterbug.Containser,
) http.HandlerFunc

NewDevoirHandleFunc creates a HTTP request handler for receiving UI commands and sending out some world state useful to the UI.

The handler upgrades the HTTP request to a websocket. The websocket's first ever incoming message should be a valid shutterbug.

Types

type Devoir

type Devoir struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

A Devoir collects certain UI commands from clients and also distrubutes some world state events to clients.

func NewDevoir

func NewDevoir(l *log.Logger, spec InitialState) *Devoir

NewDevoir constructs a new Devoir.

func (*Devoir) Paused

func (dvr *Devoir) Paused()

Paused lets clients know the new play/pause state is paused.

func (*Devoir) Playing

func (dvr *Devoir) Playing()

Playing lets clients know the new play/pause state is playing.

func (*Devoir) Pop

func (dvr *Devoir) Pop() (UICommand, error)

Pop a UI command event from the front of the commands queue.

func (*Devoir) RemoveShutterbug

func (dvr *Devoir) RemoveShutterbug(shutterbug string)

RemoveShutterbug from the devoir closing the associated HTTP request handlers using that shutterbug.

type InitialState

type InitialState struct {
	IsPaused bool
}

InitialState specifies the initial world state used by the Devoir.

type PauseUIC

type PauseUIC struct {
	UICommand string
}

PauseUIC is sent by a client to pause the world.

func NewPauseUIC

func NewPauseUIC() PauseUIC

type PlayUIC

type PlayUIC struct {
	UICommand string
}

PlayUIC is sent by a client to un-pause the world.

func NewPlayUIC

func NewPlayUIC() PlayUIC

type ShutdownUIC

type ShutdownUIC struct {
	UICommand string
}

ShutdownUIC is sent by a client to shutdown the world.

func NewShutdownUIC

func NewShutdownUIC() ShutdownUIC

type UICommand

type UICommand struct {
	Shutterbug string      // The command originated from a client using this shutterbug.
	Value      interface{} // An instance of one of the command types.
}

Jump to

Keyboard shortcuts

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