webrcon

package
v0.0.0-...-722ef49 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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

type OnConnectCallback struct {
	Command  string
	Callback func(response *Response)
}

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

type RconStats

type RconStats struct {
	CommandsRun        int
	CommandTimeouts    int
	Disconnects        int
	Messages           int
	CacheHits          int
	CacheMisses        int
	OnConnectCallback  int
	OnMessageCallbacks int
	OnInvokeCallbacks  int
}

RconStats holds various stats about the operation of the RCON client.

type Response

type Response struct {
	Message    string `json:"Message"`
	Identifier int    `json:"Identifier"`
	Type       string `json:"Type"`
	Stacktrace string `json:"Stacktrace"`
}

Response contains root response format

Jump to

Keyboard shortcuts

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