events

package
v0.0.0-...-4797095 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package events is responsible for notifying clients

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishError

func PublishError(subscribers []Subscriber, message string)

PublishError publishes the Error event

func PublishGameFinished

func PublishGameFinished(gameFinished GameFinished)

PublishGameFinished publishes the GameFinished event

func PublishRoundFinished

func PublishRoundFinished(roundFinished RoundFinished)

PublishRoundFinished publishes the RoundFinished event

func PublishStartGame

func PublishStartGame(startGame StartGame)

PublishStartGame publishes the StartGame event

Types

type GameFinished

type GameFinished struct {
	GameID        uuid.UUID
	PlayerResults []PlayerResult
	Winner        string
}

GameFinished is an intermediate structure for the GameFinished event

type PlayerResult

type PlayerResult struct {
	Status     string
	Score      string
	Subscriber Subscriber
}

PlayerResult holds the data specific to a player in the context of a RoundFinished or GameFinished event

type RoundFinished

type RoundFinished struct {
	GameID        uuid.UUID
	CurrentRound  int
	NextRound     int
	PlayerResults []PlayerResult
	Winner        string
	Moves         map[string]interface{}
}

RoundFinished is an intermediate structure for the RoundFinished event

type StartGame

type StartGame struct {
	GameID      uuid.UUID
	NextRound   int
	Players     []string
	Subscribers []Subscriber
}

StartGame is an intermediate structure for the StartGame event

type Subscriber

type Subscriber struct {
	Callback      *url.URL
	WebsocketConn *websocket.Conn
}

Subscriber represents an entity that will be notified with events

Jump to

Keyboard shortcuts

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