session

package
v0.0.0-...-6edf9ef Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFound = errors.New("session not found")
)

Functions

This section is empty.

Types

type JoinValidator

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

func NewJoinValidator

func NewJoinValidator(sessionRepository Repository) *JoinValidator

func (*JoinValidator) Validate

func (r *JoinValidator) Validate(data JoinValidatorData) (err error)

type JoinValidatorData

type JoinValidatorData struct {
	SessionId uuid.UUID
	PlayerId  uuid.UUID
}

type Player

type Player struct {
	Id         uuid.UUID
	Name       string
	LastUpdate time.Time
}

type Repository

type Repository interface {
	CreateSession(session Session) (*Session, error)
	AddPlayerToSession(sessionId uuid.UUID, playerId uuid.UUID) (*Session, error)
	RemovePlayerFromSession(sessionId uuid.UUID, playerId uuid.UUID) (*Session, error)
	FindSession(id uuid.UUID) (*Session, error)
	FindAllSessions() ([]*Session, error)
}

type Service

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

func NewSessionService

func NewSessionService(sessionRepository Repository) *Service

func (*Service) CreateSession

func (r *Service) CreateSession(name string, levelId uuid.UUID) (*uuid.UUID, error)

func (*Service) FindAllSessions

func (r *Service) FindAllSessions() ([]*Session, error)

func (*Service) FindSession

func (r *Service) FindSession(id uuid.UUID) (*Session, error)

func (*Service) GetUpdates

func (r *Service) GetUpdates(sessionId, playerId uuid.UUID) (*Session, error)

TODO: add some validations TODO: this method is incomplete, think about what it needs to do

func (*Service) JoinSession

func (r *Service) JoinSession(sessionId, playerId uuid.UUID) (*Session, error)

func (*Service) LeaveSession

func (r *Service) LeaveSession(sessionId, playerId uuid.UUID) error

type Session

type Session struct {
	Id      uuid.UUID
	Name    string
	Players []Player
	Level   level.EmLevel
}

Jump to

Keyboard shortcuts

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