Documentation
¶
Index ¶
- type Query
- func (query *Query) Close() error
- func (query *Query) GetInfo(ctx context.Context, attemptDecode bool) (server Server, err error)
- func (query *Query) GetOmpValidity(ctx context.Context) bool
- func (query *Query) GetPing(ctx context.Context) (ping time.Duration, err error)
- func (query *Query) GetPlayers(ctx context.Context) (players []string, err error)
- func (query *Query) GetRules(ctx context.Context) (rules map[string]string, err error)
- func (query *Query) SendQuery(ctx context.Context, opcode QueryType) (response []byte, err error)
- type QueryType
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct { Data Server // contains filtered or unexported fields }
Query stores state for masterlist queries
func (*Query) GetOmpValidity ¶ added in v1.2.0
GetOmpValidity sends and receives a packet to check if server is using open.mp or not
func (*Query) GetPlayers ¶
GetPlayers simply returns a slice of strings, score is rather arbitrary so it's omitted.
type QueryType ¶
type QueryType uint8
QueryType represents a query method from the SA:MP set: i, r, c, d, x, p
type Server ¶
type Server struct { Address string `json:"address"` Hostname string `json:"hostname"` Players int `json:"players"` MaxPlayers int `json:"max_players"` Gamemode string `json:"gamemode"` Language string `json:"language"` Password bool `json:"password"` Rules map[string]string `json:"rules"` Ping int `json:"ping"` IsOmp bool `json:"isOmp"` }
Server contains all the information retreived from the server query API.
func GetServerInfo ¶
GetServerInfo wraps a set of queries and returns a new Server object with the available fields populated. `attemptDecode` determines whether or not to attempt to decode ANSI into Unicode from servers that use different codepages such as Cyrillic. This function can panic if the socket it opens fails to close for whatever reason.