matchimpl

package
v0.0.12-entry Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 19 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

	// TimeOpTypeClearRoom used to clear room in some unexpected cases like client do not settle game.
	// We use this optype to force clear the room info.
	TimeOpTypeClearRoom timer.OpType = "match:timer_clear_room"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Impl

type Impl struct {
	Configer config.Configer[config.MatchConfig]
	MSConfig config.MatchStrategy
	// contains filtered or unexported fields
}

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

func NewDefault

func NewDefault(
	configer config.Configer[config.MatchConfig], mgrs *entry.Mgrs,
	groupChannel chan entry.Group, roomChannel chan common.Result,
	delayTimer timer.Operator[int64], options ...Option,
) *Impl

func (*Impl) AcceptInvite

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

func (*Impl) CancelMatch

func (impl *Impl) CancelMatch(ctx context.Context, uid string) error

func (*Impl) ChangeRole

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

func (*Impl) CreateGroup

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

func (*Impl) DissolveGroup

func (impl *Impl) DissolveGroup(ctx context.Context, uid string) error

func (*Impl) EnterGroup

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

func (*Impl) ExitGame

func (impl *Impl) ExitGame(ctx context.Context, uid string, roomID int64) error

func (*Impl) ExitGroup

func (impl *Impl) ExitGroup(ctx context.Context, uid string) error

func (*Impl) HandleGameResult

func (impl *Impl) HandleGameResult(result *pto.GameResult) error

func (*Impl) HandleMatchResult

func (impl *Impl) HandleMatchResult(r common.Result)

func (*Impl) Invite

func (impl *Impl) Invite(ctx context.Context, inviterUID, inviteeUID string) error

func (*Impl) KickPlayer

func (impl *Impl) KickPlayer(ctx context.Context, captainUID, kickedUID string) error

func (*Impl) Ready

func (impl *Impl) Ready(ctx context.Context, uid string) error

func (*Impl) RefuseInvite

func (impl *Impl) RefuseInvite(ctx context.Context, inviterUID, inviteeUID string, groupID int64, refuseMsg string)

func (*Impl) SetNearbyJoinGroup

func (impl *Impl) SetNearbyJoinGroup(_ context.Context, captainUID string, allow bool) error

func (*Impl) SetRecentJoinGroup

func (impl *Impl) SetRecentJoinGroup(_ context.Context, captainUID string, allow bool) error

func (*Impl) SetVoiceState

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

func (*Impl) StartMatch

func (impl *Impl) StartMatch(ctx context.Context, captainUID string) error

func (*Impl) Unready

func (impl *Impl) Unready(ctx context.Context, uid string) error

func (*Impl) UploadPlayerAttr

func (impl *Impl) UploadPlayerAttr(ctx context.Context, uid string, attr *pto.UploadPlayerAttr) error

type Option

type Option func(*Impl)

func WithMatchStrategyConfiger

func WithMatchStrategyConfiger(c config.MatchStrategy) 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