handler

package
v0.0.0-...-043cf72 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoardHandler

type BoardHandler struct {
	Games *map[string]*model.Board
}

func (*BoardHandler) HandleBoard

func (h *BoardHandler) HandleBoard(c echo.Context) error

type EventsHandler

type EventsHandler struct {
	Games            *map[string]*model.Board
	BroadcastChannel model.BroadcastChannel
	Clients          map[string][]chan *model.Cell // Maps game IDs to client channels
}

func NewEventsHandler

func NewEventsHandler(games *map[string]*model.Board, bc model.BroadcastChannel, clients map[string][]chan *model.Cell) *EventsHandler

func (*EventsHandler) HandleEvents

func (h *EventsHandler) HandleEvents(c echo.Context) error

HandleEvents sets up an SSE connection and listens for updates to send to the client.

func (*EventsHandler) ListenToBroadcasts

func (h *EventsHandler) ListenToBroadcasts()

ListenToBroadcasts starts listening to the broadcast channel and forwards events to relevant clients.

type HomeHandler

type HomeHandler struct{}

By keeping an independent handler for each route, we can easily have separetion of concerns and also keep the codebase maintainable and readable. This is also good for testing as we can easily test each handler independently.

func (*HomeHandler) HandleHome

func (h *HomeHandler) HandleHome(c echo.Context) error

type NewGameHandler

type NewGameHandler struct {
	Games *map[string]*model.Board
}

func (*NewGameHandler) HandleNewGame

func (h *NewGameHandler) HandleNewGame(c echo.Context) error

type PlayHandler

type PlayHandler struct {
	Games            *map[string]*model.Board
	BroadcastChannel model.BroadcastChannel
}

func (*PlayHandler) HandlePlay

func (h *PlayHandler) HandlePlay(c echo.Context) error

Jump to

Keyboard shortcuts

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