Documentation
¶
Overview ¶
Package steam allows querying of Source servers.
Index ¶
- Variables
- func SetLog(l *logrus.Logger)
- type ConnectOption
- type DialFn
- type Environment
- type InfoResponse
- type Player
- type PlayersInfoResponse
- type Server
- func (s *Server) Close()
- func (s *Server) Info() (*InfoResponse, error)
- func (s *Server) Ping() (time.Duration, error)
- func (s *Server) PlayersInfo() (*PlayersInfoResponse, error)
- func (s *Server) Send(cmd string) (string, error)
- func (s *Server) Stats() (*StatsResponse, error)
- func (s *Server) String() string
- type ServerType
- type StatsResponse
- type VAC
- type Visibility
Constants ¶
This section is empty.
Variables ¶
var ( ErrRCONAuthFailed = errors.New("steam: authentication failed") ErrRCONNotInitialized = errors.New("steam: rcon is not initialized") ErrInvalidResponseType = errors.New("steam: invalid response type from server") ErrInvalidResponseID = errors.New("steam: invalid response id from server") ErrInvalidResponseTrailer = errors.New("steam: invalid response trailer from server") )
Errors introduced by the steam client.
Functions ¶
Types ¶
type ConnectOption ¶
type ConnectOption func(*connectOptions)
ConnectOption configures how we set up the connection.
func WithDialFn ¶
func WithDialFn(fn DialFn) ConnectOption
WithDialFn returns a ConnectOption which sets a dialFn for establishing connection to the server.
func WithRCONPassword ¶
func WithRCONPassword(password string) ConnectOption
WithRCONPassword returns a ConnectOption which sets a rcon password for authenticating the connection to the server.
type DialFn ¶
The DialFn type is an adapter to allow the use of a custom network dialing mechanism when required. For example, this will come useful inside a environment like AppEngine which does not permit direct socket connections and requires the usage of a custom dialer.
type Environment ¶
type Environment int
Environment indicates the server's host environment.
const ( // EInvalid indicates a invalid host environment. EInvalid Environment = iota // ELinux indicates that the server is hosted on Linux. ELinux // EWindows indicates that the server is hosted on Windows. EWindows // EMac indicates that the server is hosted on Mac OS X. EMac )
func (Environment) String ¶
func (e Environment) String() string
type InfoResponse ¶
type InfoResponse struct {
Protocol int
Name string
Map string
Folder string
Game string
ID int
Players int
MaxPlayers int
Bots int
ServerType ServerType
Environment Environment
Visibility Visibility
VAC VAC
Version string
Port int
SteamID int64
SourceTVPort int
SourceTVName string
Keywords string
GameID int64
}
InfoResponse represents a response to a info query.
func (*InfoResponse) String ¶
func (r *InfoResponse) String() string
type PlayersInfoResponse ¶
type PlayersInfoResponse struct {
Players []*Player
}
PlayersInfoResponse represents a response to a player info query.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a Source engine game server.
func Connect ¶
func Connect(addr string, opts ...ConnectOption) (_ *Server, err error)
Connect to the source server.
func (*Server) Close ¶
func (s *Server) Close()
Close releases the resources associated with this server.
func (*Server) Info ¶
func (s *Server) Info() (*InfoResponse, error)
Info retrieves server information.
func (*Server) PlayersInfo ¶
func (s *Server) PlayersInfo() (*PlayersInfoResponse, error)
PlayersInfo retrieves player information from the server.
func (*Server) Stats ¶
func (s *Server) Stats() (*StatsResponse, error)
Stats retrieves server stats.
type ServerType ¶
type ServerType int
ServerType indicates the type of the server.
const ( // STInvalid describes a invalid server type. STInvalid ServerType = iota // STDedicated indicates a dedicated server type. STDedicated // STNonDedicated indicates a non dedicated server type. STNonDedicated // STProxy indicates a proxy server type. STProxy )
func (ServerType) String ¶
func (st ServerType) String() string
type StatsResponse ¶
type StatsResponse struct {
CPU int
NetIn float64
NetOut float64
Uptime int
Maps int
FPS float64
Players int
Sv float64
SvDeviation float64
Tick float64
}
StatsResponse represents a stats response from server.
srcds typically sends the following output:
CPU NetIn NetOut Uptime Maps FPS Players Svms +-ms ~tick 10.0 241763.2 1518923.5 10419 58 127.98 16 3.72 1.56 0.36
func (*StatsResponse) String ¶
func (r *StatsResponse) String() string
type Visibility ¶
type Visibility int
Visibility indicates the visibility of the server.
const ( // VInvalid indicates a invalid visibility. VInvalid Visibility = iota // VPublic indicates a publicly visibly server. VPublic // VPrivate indicates a private server. VPrivate )
func (Visibility) String ¶
func (v Visibility) String() string