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

Link to this function command(host, command) View Source
command(host(), String.t()) :: {:ok, String.t()} | {:error, atom()}

Run an arbitrary rcon command on a connected server, using the default port

Link to this function command(host, port, command) View Source
command(host(), integer(), String.t()) :: {:ok, String.t()} | {:error, atom()}

Run an arbitrary rcon command on a connected server

Returning: {:ok, raw_response} when successful

Returning: {:error, reason} when unsuccessful

Link to this function connect(server_info) View Source
connect(%HLDSRcon.ServerInfo{host: term(), password: term(), port: term()}) ::
  {:ok, pid()} | {:error, atom()}

Connect to a HLDS server, using the HLDSRcon.ServerInfo struct to specify server information

Link to this function connect(host, password) View Source
connect(host(), String.t()) :: {:ok, pid()} | {:error, atom()}

Connect to a HLDS server at host with password, default port will be used

Link to this function connect(host, port, password) View Source
connect(host(), integer(), String.t()) :: {:ok, pid()} | {:error, atom()}

Connect to a HLDS server at host:port with password

Link to this function disconnect(host) View Source
disconnect(host()) :: {:ok, atom()}

Cleaning disconnect a connected client at host with default port

Link to this function disconnect(host, port) View Source
disconnect(host(), integer()) :: {:ok, atom()}

Cleaning disconnect a connected client at host:port

Link to this function stats(host) View Source
stats(host()) :: {:ok, HLDSRcon.ServerInfo.t()} | {:error, atom()}

Get result of running rcon stats command on a connected server, using the default port

Link to this function stats(host, port) View Source
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