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.
Click to show internal directories.
Click to hide internal directories.