impl

package
v0.0.6-asynq Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 15 Imported by: 0

README

Match Service

Delay Timers

The Delay Timer system ensures that certain operations such as group dissolution, match cancellation, and attribute uploads are managed within specified time limits to enhance user experience and system reliability.

Purpose

The Delay Timer system manages three main types of timeouts:

  1. Group Invitation Timeout (TimerOpTypeGroupInvite):
    • Purpose: Automatically dissolves groups that do not start a match within a specified delay to save memory.
    • Trigger: Dissolves the group and notifies players if the timeout expires.
  2. Match Timeout (TimerOpTypeGroupMatch):
    • Purpose: Cancels matches that have not successfully started within a specified delay.
    • Trigger: Cancels the match and notifies players if the timeout expires.
  3. Attribute Upload Timeout (TimerOpTypeGroupWaitAttr):
    • Purpose: Ensures all players upload necessary attributes for the game within a specified delay. If not, the match is forced to start.
    • Trigger: Forces the match to start if the timeout expires.
Diagram

The diagram below illustrates the relationships and transitions between different operations and their corresponding timers:

img.png

Documentation

Index

Constants

View Source
const (
	// TimerOpTypeGroupInvite used to dissolve the group if it not starts game after delay.
	TimerOpTypeGroupInvite timer.OpType = "match:timer_group_invite"

	// TimerOpTypeGroupMatch if used to cancel match if the group not matched after delay.
	TimerOpTypeGroupMatch timer.OpType = "match:timer_group_match"

	// TimerOpTypeGroupWaitAttr used to wait for players to upload attributes after client clicks `StartMatch`.
	// If all players upload attributes, the group would start to match.
	// If timeout. the group would auto start to match.
	TimerOpTypeGroupWaitAttr timer.OpType = "match:timer_group_wait_attr" // nolint
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Impl

type Impl struct {
	DelayConfig config.DelayTimer
	// contains filtered or unexported fields
}

Impl implements a default service, in most cases, you don't need to implement your own service.

func NewDefault

func NewDefault(
	groupPlayerLimit int,
	playerMgr *repository.PlayerMgr, groupMgr *repository.GroupMgr,
	groupChannel chan entry.Group, roomChannel chan entry.Room,
	options ...Option,
) *Impl

func (*Impl) AcceptInvite

func (impl *Impl) AcceptInvite(inviterUID string, inviteeInfo *pto.PlayerInfo, groupID int64) error

func (*Impl) CancelMatch

func (impl *Impl) CancelMatch(uid string) error

func (*Impl) ChangeRole

func (impl *Impl) ChangeRole(captainUID, targetUID string, role entry.GroupRole) error

func (*Impl) CreateGroup

func (impl *Impl) CreateGroup(param *pto.CreateGroup) (entry.Group, error)

func (*Impl) DissolveGroup

func (impl *Impl) DissolveGroup(uid string) error

func (*Impl) EnterGroup

func (impl *Impl) EnterGroup(info *pto.EnterGroup, groupID int64) error

func (*Impl) ExitGroup

func (impl *Impl) ExitGroup(uid string) error

func (*Impl) HandleMatchResult

func (impl *Impl) HandleMatchResult(r entry.Room)

func (*Impl) Invite

func (impl *Impl) Invite(inviterUID, inviteeUID string) error

func (*Impl) KickPlayer

func (impl *Impl) KickPlayer(captainUID, kickedUID string) error

func (*Impl) RefuseInvite

func (impl *Impl) RefuseInvite(inviterUID, inviteeUID string, groupID int64, refuseMsg string)

func (*Impl) SetNearbyJoinGroup

func (impl *Impl) SetNearbyJoinGroup(captainUID string, allow bool) error

func (*Impl) SetRecentJoinGroup

func (impl *Impl) SetRecentJoinGroup(captainUID string, allow bool) error

func (*Impl) SetVoiceState

func (impl *Impl) SetVoiceState(uid string, state entry.PlayerVoiceState) error

func (*Impl) StartMatch

func (impl *Impl) StartMatch(captainUID string) error

type Option

type Option func(*Impl)

func WithDelayConfiger

func WithDelayConfiger(t config.DelayTimer) Option

func WithDelayTimer

func WithDelayTimer(t timer.Operator[int64]) Option

func WithNowFunc

func WithNowFunc(f func() int64) Option

Jump to

Keyboard shortcuts

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