HLDSRcon v1.0.1 HLDSRcon View Source
A library for creating Half-Life Dedicated Server (a.k.a “HLDS”) remote connections (a.k.a “rcon”) and executing commands.
Uses a DynamicSupervisor
for connecting clients. If you want to manage the rcon client supervision
yourself you can use the HLDSRcon.RconClient
module directly.
Examples
If you are running a server on the localhost with the HLDS rcon_password
set to Foo
, you would connect;
{:ok, _pid} = HLDSRcon.connect("127.0.0.1", "Foo")
Now that the connection is established, you can run commands;
{:ok, _response} = HLDSRcon.command("127.0.0.1", "echo Test")
Some common command responses are processed into structs for ease of use;
{:ok, %HLDSRcon.Stats{} = stats} = HLDSRcon.command("127.0.0.1", "stats")
These common commands also have entry points in this module, e.g. instead of calling command to run stats as above, we could simply call;
{
:ok,
%HLDSRcon.Stats{
cpu: 11.33,
fps: 921.12,
in: 0.0,
out: 0.0,
players: 0,
uptime: 895,
users: 0
}
} = HLDSRcon.stats("127.0.0.1")
Link to this section Summary
Functions
Run an arbitrary rcon command on a connected server, using the default port
Run an arbitrary rcon command on a connected server
Connect to a HLDS server, using the HLDSRcon.ServerInfo
struct to specify server information
Connect to a HLDS server at host with password, default port will be used
Connect to a HLDS server at host:port with password
Cleaning disconnect a connected client at host
with default port
Cleaning disconnect a connected client at host
:port
Get result of running rcon stats
command on a connected server, using the default port
Get the result of running rcon stats
on a connected server
Link to this section Types
Link to this section Functions
Run an arbitrary rcon command on a connected server, using the default port
Run an arbitrary rcon command on a connected server
Returning: {:ok, raw_response}
when successful
Returning: {:error, reason}
when unsuccessful
Connect to a HLDS server, using the HLDSRcon.ServerInfo
struct to specify server information
Connect to a HLDS server at host with password, default port will be used
Connect to a HLDS server at host:port with password
Cleaning disconnect a connected client at host
with default port
Cleaning disconnect a connected client at host
:port
stats(host()) :: {:ok, HLDSRcon.ServerInfo.t()} | {:error, atom()}
Get result of running rcon stats
command on a connected server, using the default port
stats(host(), integer()) :: {:ok, HLDSRcon.ServerInfo.t()} | {:error, atom()}
Get the result of running rcon stats
on a connected server
Returning: {:ok, %HLDSRcon.Stats{}}
when successful
Returning: {:error, reason}
when unsuccessful