matchmaking

package
v0.0.0-...-8161148 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PlayerPool

type PlayerPool struct {
	sync.Mutex
	Players []*game.Network
	// contains filtered or unexported fields
}

PlayerPool is the pool of unmatched players waiting in the match queue

func NewPlayerPool

func NewPlayerPool() *PlayerPool

func (*PlayerPool) AddPlayer

func (p *PlayerPool) AddPlayer(player *game.Network)

func (*PlayerPool) FindMatch

func (p *PlayerPool) FindMatch() (*game.Network, *game.Network)

FindMatch finds a match for two players and removes them from the pool

func (*PlayerPool) RemovePlayer

func (p *PlayerPool) RemovePlayer(player *game.Network)

func (*PlayerPool) StartMatchmaking

func (p *PlayerPool) StartMatchmaking()

StartMatchmaking is responsible for constantly checking the match queue for players and starting a new game session when two players are found.

The matchSignal channel is used to trigger the matchmaking process and it's supposed to be triggered every time a new player joins the pool. Otherwise, it will block.

The matching process only considers the first two players in the queue.

Jump to

Keyboard shortcuts

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