Cauldron2D.Beacon.Listener (Cauldron2D v0.1.3)

Copy Markdown View Source

Hears the servers of one game calling on the local network (Cauldron2D.Beacon) and keeps those heard in the last six seconds.

{:ok, _} = Cauldron2D.Beacon.Listener.start_link(game: :my_game)
Cauldron2D.Beacon.Listener.found()

Options

  • :game — the game whose servers to keep; others' calls are ignored. Required
  • :port — the UDP port. Default Cauldron2D.Beacon.port/0
  • :name — the process name. Default the module, nil for none

A port it cannot open leaves it deaf, hearing nothing.

Summary

Functions

Returns a specification to start this module under a supervisor.

The servers heard in the last six seconds, the latest first.

Start listening; see the module documentation for the options.

Types

server()

@type server() :: %{
  game: String.t(),
  host: String.t(),
  http: String.t() | nil,
  node: atom() | nil,
  from: :inet.ip_address(),
  heard: integer()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

found(listener \\ __MODULE__)

@spec found(GenServer.server()) :: [server()]

The servers heard in the last six seconds, the latest first.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Start listening; see the module documentation for the options.