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