A library for communicating with game servers running Valve's A2S server query protocol.
Add :elixir_a2s
to your list of dependencies in mix.exs
:
def deps do
[
{:elixir_a2s, "~> 0.4.3"}
]
end
Documentation is available on HexDocs and may also be generated with ExDoc.
There's two general ways to use this library:
An easy to use client that should cover most use cases.
Add A2S.Client
to your app's supervision tree:
children = [
{A2S.Client, []}
]
Or start the client dynamically:
A2S.Client.start_link()
Afterwards, querying a game server's as simple as:
A2S.Client.query(:info, {{127, 0, 0, 1}, 20000}) # ipv4 address followed by the query port
-
A2S.Client
assumes a singleton pattern by default. -
For configuring multiple instances, see
A2S.Client.start_link/1
andA2S.Client.query/3
.
This module provides functions form requests, sign challenges, and parse responses for the A2S protocol. You can utilize this module directly in your application for tighter integration, but in turn you'll have to roll your own packet assembly. See Using A2S Directly guide for further details.
Source 2006 (aka "Pre-Orange Box") servers
Most source games are running on newer versions of the engine.
Many GoldSrc servers use the current standard, so this should impact few games.
Uses proprietary fields only worth supporting for posterity-sake.
Considered deprecated by Valve and is unsupported by almost all most games.
Only used by a handful of niche games, and the normal challenge flow should work anyway.
By default Elixir will ignore :gen_statem
crashes. To receive them, add the following to your application:
Logger.add_translator({A2S.StateMachineTranslator, :translate})