services

package
v0.0.0-...-abd2ee0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

type AuthService struct{}

func (AuthService) AccessTokenClaims

func (service AuthService) AccessTokenClaims(user models.Player) (claims jwt.MapClaims)

Generates claims to sign with the access token.

func (AuthService) GenerateTokens

func (service AuthService) GenerateTokens(user models.Player) (models.AuthenticationResponse, error)

func (AuthService) RefreshTokenClaims

func (service AuthService) RefreshTokenClaims(user models.Player) (claims jwt.MapClaims)

Generates claims to sign with the refresh token.

type Creators

type Creators struct {
	InstanceCreator models.Creator
	MessageCreator  models.WebsocketMessageCreator
	ErrorCreator    errors.ErrorMessageCreator
}

type MatchService

type MatchService struct {
	Crud db.MatchCrud

	SubscriberService SubscriberService
}

func (MatchService) CreateMatch

func (service MatchService) CreateMatch(player models.Player, specs models.Specs) (quiz models.Game, err error)

func (MatchService) FindActiveMatchesForPlayer

func (service MatchService) FindActiveMatchesForPlayer(playerId string) (matches []models.Game, err error)

func (MatchService) UpdateMatchTags

func (service MatchService) UpdateMatchTags(match models.Game, tag string) (bool, error)

type PermissionService

type PermissionService struct {
	Crud db.PermissionCrud
}

func (PermissionService) HasPermissions

func (servie PermissionService) HasPermissions(playerId string) bool

type PlayerService

type PlayerService struct {
	Crud db.PlayerCrud
}

func (PlayerService) FindOrCreatePlayer

func (service PlayerService) FindOrCreatePlayer(request models.Player) (player models.Player, err error)

func (PlayerService) FindPlayerByEmail

func (service PlayerService) FindPlayerByEmail(email string) (player models.Player, err error)

func (PlayerService) FindPlayers

func (service PlayerService) FindPlayers(playerIds []string) (players []models.Player, err error)

type QuestionService

type QuestionService struct {
	Crud db.QuestionCrud
}

func (QuestionService) AddQuestion

func (service QuestionService) AddQuestion(tag string, newQuestions []models.NewQuestion) (err error)

func (QuestionService) FindQuestionForMatch

func (service QuestionService) FindQuestionForMatch(match models.Game) (question models.Question, err error)

type Service

type Service struct {
	AuthService       AuthService
	PermissionService PermissionService
	MatchService      MatchService
	SubscriberService SubscriberService
	PlayerService     PlayerService
	TeamService       TeamService
	QuestionService   QuestionService
	SnapshotService   SnapshotService
	Validator         Validator
	TargetService     TargetService
	Creators          Creators
}

func Init

func Init(Db db.DBConn) (service Service)

func (Service) DeletePlayerLiveSession

func (service Service) DeletePlayerLiveSession(playerId string) (res models.WebsocketMessage, targets map[string]bool, err error)

func (Service) FindMatchFull

func (service Service) FindMatchFull(matchId string) (
	match models.Game, teams []models.Team,
	subscribers []models.Subscriber, players []models.Player,
	roster []models.TeamRoster,
	snapshot models.Snapshot, err error)

func (Service) GenerateBeginGameResponse

func (service Service) GenerateBeginGameResponse(player models.Player) (res models.LoginResponse, err error)

func (Service) GenerateCreateGameResponse

func (service Service) GenerateCreateGameResponse(quizmaster models.Player, specs models.Specs) (response models.GameResponse, err error)

func (Service) GenerateEnterGameResponse

func (service Service) GenerateEnterGameResponse(request models.Request) (response models.GameResponse, err error)

func (Service) GenerateFinishGameResponse

func (service Service) GenerateFinishGameResponse(request models.Request) (response models.Snapshot, err error)

func (Service) GenerateFullMatchResponse

func (service Service) GenerateFullMatchResponse(quizId string) (response models.Snapshot, err error)

func (Service) GenerateGameResponse

func (service Service) GenerateGameResponse(request models.Request) (response models.Snapshot, err error)

func (Service) GenerateNextQuestionResponse

func (service Service) GenerateNextQuestionResponse(request models.Request) (response models.Snapshot, err error)

func (Service) GeneratePassQuestionResponse

func (service Service) GeneratePassQuestionResponse(request models.Request) (response models.Snapshot, err error)

func (Service) GenerateQuestionAnswerResponse

func (service Service) GenerateQuestionAnswerResponse(request models.Request) (response models.Snapshot, err error)

func (Service) GenerateQuestionHintResponse

func (service Service) GenerateQuestionHintResponse(request models.Request) (response models.Snapshot, err error)

func (Service) GenerateScoreResponse

func (service Service) GenerateScoreResponse(request models.Request) (response models.ScoreResponse, err error)

func (Service) GenerateStartGameResponse

func (service Service) GenerateStartGameResponse(request models.Request) (response models.Snapshot, err error)

func (Service) GenerateWatchGameResponse

func (service Service) GenerateWatchGameResponse(request models.Request) (response models.GameResponse, err error)

type SnapshotService

type SnapshotService struct {
	Crud db.SnapshotCrud
}

func (SnapshotService) CreateSnapshot

func (service SnapshotService) CreateSnapshot(snapshot models.Snapshot) (err error)

func (SnapshotService) FindSnapshotsForMatch

func (service SnapshotService) FindSnapshotsForMatch(matchId string) (snapshots []models.Snapshot, err error)

func (SnapshotService) FindSnapshotsForQuestion

func (service SnapshotService) FindSnapshotsForQuestion(quizId string, questionId string, eventType string) (snapshots []models.Snapshot, err error)

func (SnapshotService) InitialSnapshot

func (service SnapshotService) InitialSnapshot(quizId string, teams []models.Team) (response models.Snapshot, err error)

func (SnapshotService) SnapshotAnswer

func (service SnapshotService) SnapshotAnswer(snapshot models.Snapshot, roster []models.TeamRoster, answer models.Answer, points int) (response models.Snapshot, err error)

func (SnapshotService) SnapshotDrop

func (service SnapshotService) SnapshotDrop(snapshot models.Snapshot, roster []models.TeamRoster) (response models.Snapshot, err error)

func (SnapshotService) SnapshotFinish

func (service SnapshotService) SnapshotFinish(snapshot models.Snapshot, roster []models.TeamRoster) (response models.Snapshot, err error)

func (SnapshotService) SnapshotHint

func (service SnapshotService) SnapshotHint(snapshot models.Snapshot, roster []models.TeamRoster, hint []string) (response models.Snapshot, err error)

func (SnapshotService) SnapshotJoin

func (service SnapshotService) SnapshotJoin(snapshot models.Snapshot, roster []models.TeamRoster) (response models.Snapshot, err error)

func (SnapshotService) SnapshotNext

func (service SnapshotService) SnapshotNext(snapshot models.Snapshot, roster []models.TeamRoster, question models.Question, teamsTurn string) (response models.Snapshot, err error)

func (SnapshotService) SnapshotPass

func (service SnapshotService) SnapshotPass(snapshot models.Snapshot, roster []models.TeamRoster, teamsTurn string, roundNo int, specs models.Specs) (response models.Snapshot, err error)

func (SnapshotService) SnapshotStart

func (service SnapshotService) SnapshotStart(snapshot models.Snapshot, roster []models.TeamRoster, question models.Question, teamsTurn string) (response models.Snapshot, err error)

type SubscriberService

type SubscriberService struct {
	Crud db.SubscriberCrud

	TargetService TargetService

	Creators Creators
}

func (SubscriberService) FindOrCreateSubscriber

func (service SubscriberService) FindOrCreateSubscriber(tag string, audience models.Player, role actions.Role) (subscriber models.Subscriber, err error)

func (SubscriberService) FindPlayerIdsFromSubscribers

func (service SubscriberService) FindPlayerIdsFromSubscribers(subscribers []models.Subscriber) (playerIds []string)

func (SubscriberService) FindSubscribers

func (service SubscriberService) FindSubscribers(tag string, role actions.Role) (subscribers []models.Subscriber, err error)

func (SubscriberService) FindSubscribersForTags

func (service SubscriberService) FindSubscribersForTags(tags []string) (subscribers []models.Subscriber, err error)

func (SubscriberService) FindSubscriptionsForPlayerId

func (service SubscriberService) FindSubscriptionsForPlayerId(playerId string) (subscribers []models.Subscriber, err error)

func (SubscriberService) QuizResponse

func (service SubscriberService) QuizResponse(action string, quizId string, response models.Snapshot) (res models.WebsocketMessage, targets map[string]bool)

func (SubscriberService) SelfResponse

func (service SubscriberService) SelfResponse(playerId string, action actions.Action, response interface{}) (res models.WebsocketMessage, targets map[string]bool)

func (SubscriberService) SubscribeAndRespond

func (service SubscriberService) SubscribeAndRespond(match models.Game, player models.Player, snapshot models.Snapshot, role actions.Role) (response models.GameResponse, err error)

type TargetService

type TargetService struct{}

func (TargetService) TargetQuiz

func (target TargetService) TargetQuiz(quizId string, subscribers []models.Subscriber) (targets map[string]bool)

func (TargetService) TargetSelf

func (target TargetService) TargetSelf(playerId string) (targets map[string]bool)

type TeamService

type TeamService struct {
	Crud db.TeamCrud

	SubscriberService SubscriberService
}

func (TeamService) CreateTeams

func (service TeamService) CreateTeams(quiz models.Game) (teams []models.Team, err error)

func (TeamService) FindAndFillTeamVacancy

func (service TeamService) FindAndFillTeamVacancy(match models.Game, teams []models.Team, player models.Player) (teamId string, err error)

func (TeamService) FindTeamIdsFromTeams

func (service TeamService) FindTeamIdsFromTeams(teams []models.Team) (teamIds []string)

func (TeamService) FindTeams

func (service TeamService) FindTeams(quizId string) (teams []models.Team, err error)

func (TeamService) FindVacantTeamId

func (service TeamService) FindVacantTeamId(teams []models.Team, subscribers []models.Subscriber, playersCount int) (teamId string)

type Validator

type Validator struct{}

func (Validator) ValidateBeginRequest

func (validator Validator) ValidateBeginRequest(request models.Request) (err error)

func (Validator) ValidateCreateQuizRequest

func (validator Validator) ValidateCreateQuizRequest(request models.Request) (err error)

func (Validator) ValidateRefeshQuizRequest

func (validator Validator) ValidateRefeshQuizRequest(request models.Request) (err error)

func (Validator) ValidateRequest

func (validator Validator) ValidateRequest(request models.Request) (err error)

Jump to

Keyboard shortcuts

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