Documentation ¶
Index ¶
- type BaseService
- func (s *BaseService) PublishControl(ctx context.Context, ctrl Control)
- func (s *BaseService) PublishEvent(_ context.Context, event Event)
- func (s *BaseService) RegisterController(c ClientConnection)
- func (s *BaseService) RegisterScreen(c ClientConnection)
- func (s *BaseService) UnregisterController(c ClientConnection)
- func (s *BaseService) UnregisterScreen(c ClientConnection)
- type ClientConnection
- type Control
- type Event
- type Score
- type ScoreStore
- type Service
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseService ¶
type BaseService struct {
// contains filtered or unexported fields
}
BaseService is a messaging hub.
func (*BaseService) PublishControl ¶
func (s *BaseService) PublishControl(ctx context.Context, ctrl Control)
PublishControl publishes a control to the messaging bus.
func (*BaseService) PublishEvent ¶
func (s *BaseService) PublishEvent(_ context.Context, event Event)
PublishEvent publishes an event to the messaging bus.
func (*BaseService) RegisterController ¶
func (s *BaseService) RegisterController(c ClientConnection)
RegisterController registers a new controller.
func (*BaseService) RegisterScreen ¶
func (s *BaseService) RegisterScreen(c ClientConnection)
RegisterScreen registers a new screen.
func (*BaseService) UnregisterController ¶
func (s *BaseService) UnregisterController(c ClientConnection)
UnregisterController removes a controller.
func (*BaseService) UnregisterScreen ¶
func (s *BaseService) UnregisterScreen(c ClientConnection)
UnregisterScreen removes a screen.
type ClientConnection ¶
ClientConnection is a connection with a client.
type Control ¶
type Control struct { Type string `json:"type"` Player User `json:"player"` Color string `json:"color"` PosX float64 `json:"posX"` PosY float64 `json:"posY"` VelocityX float64 `json:"velocityX"` VelocityY float64 `json:"velocityY"` FinalScore int64 `json:"finalScore"` }
Control is a message sent from a controller.
type Event ¶
type Event struct { Type string `json:"type"` Player User `json:"player"` Points int64 `json:"points"` }
Event is a message sent to a controller.
type Score ¶
type Score struct { ID string `json:"id"` Player User `json:"player"` FinalScore int64 `json:"finalScore"` Color string `json:"color"` }
Score is a score of a player.
type ScoreStore ¶
type ScoreStore interface { ListAll(ctx context.Context) ([]*Score, error) Add(ctx context.Context, scr *Score) error RemoveAll(ctx context.Context) error }
ScoreStore is a store of scores.
type Service ¶
type Service interface { RegisterScreen(screen ClientConnection) UnregisterScreen(screen ClientConnection) RegisterController(controller ClientConnection) UnregisterController(controller ClientConnection) PublishEvent(ctx context.Context, event Event) PublishControl(ctx context.Context, ctrl Control) }
Service is a messaging hub for events.
Click to show internal directories.
Click to hide internal directories.