master

package
v1.0.233 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

A master server keeps track of all public q2 servers. Q2 servers need to specifically be told to report to a master server.

Index

Constants

View Source
const (
	DefaultListenPort    = 27900
	DefaultListenAddr    = "[::]" // IPv4/IPv6 all
	DefaultThinkInterval = 360    // secs
	DefaultPingInterval  = 360    // secs
	DefaultApiPort       = 3333
	DefaultApiAddr       = "[::]"
	DefaultApiEnabled    = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MasterClient

type MasterClient struct {
	Address     net.Addr // ip and port (192.0.2.1:27910)
	IP          net.IP
	Port        int
	Hostname    string
	GameDir     string
	MaxPlayers  int
	Players     []MasterClientPlayer
	LastContact time.Time
	Heartbeats  int
	Missedbeats int
	PendingAcks int
	Active      bool
	Info        map[string]string
}

A public Q2 server, also a client for the master

func (*MasterClient) Marshal

func (cl *MasterClient) Marshal() *message.Buffer

Write this MasterClient's IP and port in a format that can be sent as a response

type MasterClientPlayer

type MasterClientPlayer struct {
	Name  string // 15 chars max
	Score int    // specs will be 0
	Ping  int
}

type MasterServer

type MasterServer struct {
	Address        string // IP or DNS name
	Port           int    // default 27900
	ApiEnabled     bool
	ApiIP          string
	ApiPort        int
	Clients        []MasterClient  // our known q2 server
	Conn           *net.PacketConn // the socket
	ThinkInterval  int             // seconds between thinks
	PingInterval   int
	ThinkFunc      func(m *MasterServer)
	ProcessFunc    func(m *MasterServer)
	ClientListFunc func(m *MasterServer, recip *net.Addr)
	HeartbeatFunc  func(m *MasterServer, from *net.Addr, info map[string]string)
	PingFunc       func(m *MasterServer, from *net.Addr) *MasterClient
	AckFunc        func(m *MasterServer, from *net.Addr)
	ShutdownFunc   func(m *MasterServer, from *net.Addr)
	Stats          MasterServerStats
}

the all-knowning master server

func NewMaster added in v1.0.87

func NewMaster() *MasterServer

Setup a new server struct with default function calls and values

func (MasterServer) FetchServers

func (m MasterServer) FetchServers() ([]MasterClient, error)

Grab all servers

func (*MasterServer) FindClient

func (m *MasterServer) FindClient(cl net.Addr) *MasterClient

func (*MasterServer) HeartbeatCount

func (m *MasterServer) HeartbeatCount() int

func (*MasterServer) MarshalClients

func (m *MasterServer) MarshalClients() *message.Buffer

Write all MasterClient's info to a buffer for responding

func (*MasterServer) Run added in v1.0.87

func (m *MasterServer) Run()

start the actual server

func (MasterServer) SendClientList

func (m MasterServer) SendClientList()

dont do this

type MasterServerStats

type MasterServerStats struct {
	StartTime     time.Time // when the server started
	ApiHits       int       // how many times the API has been queried
	GetServerHits int       // how many times GetServers/query was issued
}

Jump to

Keyboard shortcuts

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