matchmaker

package module
v0.0.0-...-0541670 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 9 Imported by: 0

README

MatchMaker

Matchmaker example to incorporate into the Agones kubernetes environment. The matchmaker is based on kuy.

The matchmaker example incorporates the Agones kubernetes API to find a server and can be used in any environments by only adapting the config.json file.

MatchMaker Agones example

Generate new UUIDs with /register:

# curl http://localhost:8001/register
3465284411

Join a match as a player (player id 1 and 2) with /join. Returns the match ID and some parameters. No match

# curl http://localhost:8001/join?id=1
{"MatchmakingID":1409079322,"IsFull":false,"CurrentPlayers":1,"MaxPlayers":5,"ServerPort":0,"ServerHost":""}
# curl http://localhost:8001/join?id=2
{"MatchmakingID":1409079322,"IsFull":false,"CurrentPlayers":2,"MaxPlayers":5,"ServerPort":0,"ServerHost":""}

For testing purposes you can automate multiple players to join:

# curl -s "http://localhost:8001/join?id=[1-10]"

Find match with /match:

# curl http://localhost:8001/match?id=1409079322
{"MatchmakingID":1409079322,"IsFull":true,"CurrentPlayers":5,"MaxPlayers":5,"ServerPort":7080,"ServerHost":"127.0.0.1"}

Please see the agones/example directory for more info

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgonesOption

type AgonesOption struct {
	Port      int
	Host      string
	FleetName string
}

AgonesOption struct define engine option configuration

type MatchMaker

type MatchMaker struct {
	WaitTime time.Duration
	// contains filtered or unexported fields
}

MatchMaker struct hold required data, and act as function receiver

func New

func New(opt Option) *MatchMaker

New function return MatchMaker struct

func (*MatchMaker) GetNumberOfPools

func (m *MatchMaker) GetNumberOfPools() int

GetNumberOfPools return number of pools

func (*MatchMaker) GetPool

func (m *MatchMaker) GetPool(poolID uint32) *PoolResp

GetPool return number of pools

func (*MatchMaker) Join

func (m *MatchMaker) Join(playerID uint32) *PoolResp

Join an active or new pool

type Option

type Option struct {
	MaxPlayers int
	WaitTime   time.Duration
}

Option struct define engine option configuration

type PoolResp

type PoolResp struct {
	PoolID   uint32
	IsFull   bool
	TimeIsUp bool
	Players  []uint32
	Gs       *allocation.GameServerAllocation
}

PoolResp is the response for joining the pool

type ServerFinder

type ServerFinder struct {
	// contains filtered or unexported fields
}

ServerFinder struct hold required data

func NewFinder

func NewFinder(opt AgonesOption) *ServerFinder

NewFinder function return ServerFinder struct

func (*ServerFinder) GetServer

func (s *ServerFinder) GetServer(poolID uint32, ch chan<- *allocation.GameServerAllocation)

GetServer get game server struct

Jump to

Keyboard shortcuts

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