Documentation
¶
Index ¶
- Constants
- type ChatMessage
- type Command
- type OnConnectCallback
- type OnMessageCallback
- type PlayerList
- type RconCallback
- type RconClient
- func (client *RconClient) InitClient(host string, port int, password string)
- func (client *RconClient) MaintainConnection(done chan struct{}, wg *sync.WaitGroup)
- func (client *RconClient) OnConnect(cb OnConnectCallback)
- func (client *RconClient) OnMessage(cb OnMessageCallback)
- func (client *RconClient) Send(command string)
- func (client *RconClient) SendCallback(command string, cacheFor int, callback func(response *Response))
- type RconStats
- type Response
Constants ¶
const (
// StartingIdentifier sets the starting RCON ID
StartingIdentifier = 1000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatMessage ¶
type ChatMessage struct {
Channel int `json:"Channel"`
Message string `json:"Message"`
UserID string `json:"UserId"`
Username string `json:"Username"`
Color string `json:"Color"`
Time int `json:"Time"`
}
ChatMessage contains the webrcon chat message format for Type: Chat
type Command ¶
type Command struct {
Identifier int `json:"Identifier"`
Message string `json:"Message"`
Name string `json:"Name"`
}
Command contains a standard WebRcon command structure
type OnConnectCallback ¶
OnConnectCallback contains the on connect callback functions
type OnMessageCallback ¶
type OnMessageCallback struct {
Callback func(message []byte)
}
OnMessageCallback contains the callbacks run on every RCON message
type PlayerList ¶
type PlayerList struct {
SteamID string `json:"SteamID"`
OwnerID string `json:"OwnerID"`
DisplayName string `json:"DisplayName"`
Ping int `json:"Ping"`
Address string `json:"Address"`
ConnectedSeconds int `json:"ConnectedSeconds"`
ViolationLevel float32 `json:"VoiationLevel"`
CurrentLevel float32 `json:"CurrentLevel"`
UnspentXp float32 `json:"UnspentXp"`
Health float32 `json:"Health"`
}
PlayerList contains the structure for the "playerlist" command in Rust
type RconCallback ¶
type RconCallback struct {
// contains filtered or unexported fields
}
RconCallback struct contains the information about a registered callback, and its TTL
type RconClient ¶
type RconClient struct {
Connected bool
CallOnMessageOnInvoke bool
IgnoreEmptyRconMessages bool
OnConnectDelay int
Stats RconStats
// contains filtered or unexported fields
}
RconClient maintains the connection to the Rust server.
func (*RconClient) InitClient ¶
func (client *RconClient) InitClient(host string, port int, password string)
InitClient sets up the RconClient
func (*RconClient) MaintainConnection ¶
func (client *RconClient) MaintainConnection(done chan struct{}, wg *sync.WaitGroup)
MaintainConnection is intended to be run as a goroutine and will loop forever, maintaining a connection and restablishing whenever the websocket goes down.
func (*RconClient) OnConnect ¶
func (client *RconClient) OnConnect(cb OnConnectCallback)
OnConnect registers a callback to be called on connect.
func (*RconClient) OnMessage ¶
func (client *RconClient) OnMessage(cb OnMessageCallback)
OnMessage registers a callback to be called on every raw rcon message
func (*RconClient) Send ¶
func (client *RconClient) Send(command string)
Send a command with no callback
func (*RconClient) SendCallback ¶
func (client *RconClient) SendCallback(command string, cacheFor int, callback func(response *Response))
SendCallback sends a command with a callback