service

package
v0.0.0-...-1b9e5be Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmbedFSHandler

func EmbedFSHandler(staticFS fs.FS) http.Handler

func NewRenderer

func NewRenderer() echo.Renderer

func SingleFileHandler

func SingleFileHandler(staticFS fs.FS, path, filetype string) echo.HandlerFunc

Types

type JArchiveIndex

type JArchiveIndex struct {
	Version    []uint                                    `json:"version,omitempty"`
	Seasons    map[qparty.SeasonID]qparty.SeasonMetadata `json:"seasons"`
	Categories map[string]qparty.CategoryMetadata        `json:"categories"`
	Episodes   map[qparty.EpisodeID]qparty.EpisodeStats  `json:"episodes"`
}

func (JArchiveIndex) WriteSeasonIndexJSON

func (all_seasons JArchiveIndex) WriteSeasonIndexJSON(json_path string) error

type QPartyPlayer

type QPartyPlayer struct {
	Name string `json:"name"`
}

type QPartySecret

type QPartySecret struct {
	QPartyPlayer
	Token string
}

type RoomConfig

type RoomConfig struct {
	Notes string `json:"notes,omitempty"`
}

type RoomID

type RoomID string

type RoomMetadata

type RoomMetadata struct {
	Rooms map[RoomID]RoomConfig
}

Maintains independent state for each room being managed.

type RoomState

type RoomState struct {
	Tokens     map[QPartySecret]bool
	Stream     *sse.Stream
	HostPlayer string
	// contains filtered or unexported fields
}

func NewRoomState

func NewRoomState(config RoomConfig) *RoomState

type Server

type Server struct {
	*http.Server
	Rooms map[RoomID]*RoomState
	// contains filtered or unexported fields
}

func NewServer

func NewServer(port int) *Server

func (*Server) ListCategoriesByYear

func (server *Server) ListCategoriesByYear(ctx echo.Context) error

func (*Server) LoadJArchiveIndex

func (server *Server) LoadJArchiveIndex(jarchive_json []byte) error

func (*Server) NewRandomBoard

func (server *Server) NewRandomBoard() func(ctx echo.Context) error

func (*Server) RegisterRoutes

func (server *Server) RegisterRoutes() *http.Handler

func (*Server) RouteIndexJSON

func (server *Server) RouteIndexJSON(index_name string) func(echo.Context) error

Handler for static JSON files representing parts of the index.

func (*Server) RouteInitiateUpdates

func (server *Server) RouteInitiateUpdates() func(echo.Context) error

Notifies clients of changes using SSE (server-sent events). This could also be done with websockets, and perhaps that will be necessary for STT later. Even with websocket handling, SSE is still better for audience members.

The client app (e.g. a SPA in Vue) can listen to these events and update its local path structure to match updates in game state (e.g. view categories, peer buzz-in, challenge selection, etc.) that were not initiated by a player.

func (*Server) RouteJoinRoom

func (server *Server) RouteJoinRoom(jsonFS fs.FS) func(echo.Context) error

func (*Server) RoutePlayRoom

func (server *Server) RoutePlayRoom() func(echo.Context) error

func (*Server) RouteRandomCategories

func (server *Server) RouteRandomCategories() func(echo.Context) error

func (*Server) RouteRandomChallenges

func (server *Server) RouteRandomChallenges() func(echo.Context) error

func (*Server) RouteRandomEpisode

func (server *Server) RouteRandomEpisode() func(echo.Context) error

func (*Server) RouteStaticFiles

func (server *Server) RouteStaticFiles(staticFS fs.FS)

func (*Server) Serve

func (server *Server) Serve(port int) error

func (*Server) ServeTLS

func (server *Server) ServeTLS(crt_path, key_path string) error

type TemplateRenderer

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

func (TemplateRenderer) Render

func (site TemplateRenderer) Render(w io.Writer, name string, data interface{}, ctx echo.Context) error

Jump to

Keyboard shortcuts

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