service

package
v0.0.0-...-9c769f9 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 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 GameState

type GameState struct {
	Round        int    `json:"round"`
	GameID       string `json:"gameId"`
	YourScore    int    `json:"yourScore"`
	TheirScore   int    `json:"theirScore"`
	Winner       bool   `json:"winner"`
	YourPlay     string `json:"yourPlay,omitempty"`
	TheirPlay    string `json:"theirPlay,omitempty"`
	RoundSummary string `json:"roundSummary,omitempty"`
}

GameState structures for sending to players. Fields are optional especially on setup

type LambdaSvc

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

func NewLambdaSvc

func NewLambdaSvc(store *store.Store, ws *notify.APIGWNotifier) *LambdaSvc

NewLambdaSvc returns a new lambda service

func (*LambdaSvc) Connect

func (s *LambdaSvc) Connect(e events.APIGatewayWebsocketProxyRequest) (interface{}, error)

Connect is currently a no-op

func (*LambdaSvc) Default

func (s *LambdaSvc) Default(e events.APIGatewayWebsocketProxyRequest) (interface{}, error)

func (*LambdaSvc) Disconnect

func (s *LambdaSvc) Disconnect(e events.APIGatewayWebsocketProxyRequest) (interface{}, error)

Disconnect is currently a no-op

func (*LambdaSvc) JoinGame

func (s *LambdaSvc) JoinGame(connectionID string, message PlayerMessage) error

JoinGame joins a game in progress

func (*LambdaSvc) NewGame

func (s *LambdaSvc) NewGame(connectionID string, message PlayerMessage) error

NewGame creates a new game record in the database

func (*LambdaSvc) NotifyPlayers

func (s *LambdaSvc) NotifyPlayers(gc *game.GameContext) error

NotifyPlayers sends out a notification about a game round to all connected parties

func (*LambdaSvc) Play

func (s *LambdaSvc) Play(connectionID string, message PlayerMessage) error

Play handles a single player's play.

func (*LambdaSvc) SendGameState

func (s *LambdaSvc) SendGameState(gc *game.GameContext) error

SendGameState will send a game state to a given connection

func (*LambdaSvc) SendStateMessage

func (s *LambdaSvc) SendStateMessage(gs *GameState, address string) error

type PlayerMessage

type PlayerMessage struct {
	Action string `json:"action"`
	UID    string `json:"userId"`
	GameID string `json:"gameId"`
	Play   string `json:"play"`
	Round  int    `json:"round"`
}

PlayerMessage are what we get from the players

Jump to

Keyboard shortcuts

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