Skip to content

Moosieus/elixir-a2s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elixir A2S

A library for communicating with game servers running Valve's A2S server query protocol.

Installation

Add :elixir_a2s to your list of dependencies in mix.exs:

def deps do
  [
    {:elixir_a2s, "~> 0.4.0"}
  ]
end

Documentation is available on HexDocs and may also be generated with ExDoc.

Usage

There's two general ways to use this library:

A2S.Client

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

Notes:

  • A2S.Client assumes a singleton pattern by default.

  • For configuring multiple instances, see A2S.Client.start_link/1 and A2S.Client.query/3.

A2S

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.

Unsupported games and features

Source 2006 (aka "Pre-Orange Box") servers

Most source games are running on newer versions of the engine.

GoldSrc servers not using the standard protocol

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.

Debugging

By default Elixir will ignore :gen_statem crashes. To receive them, add the following to your application:

Logger.add_translator({A2S.StateMachineTranslator, :translate})

About

A library for communicating with game servers running Valve's A2S server query protocol.

Resources

License

Stars

Watchers

Forks

Languages