Cauldron2D.Net.Load.Session (Cauldron2D.Net v0.1.2)

Copy Markdown View Source

One session of a load test: a player or a watcher on a server's arena over the same WebSocket a browser or the desktop uses (Cauldron2D.Net.Link.Socket), counting the frames it gets. A player changes what it holds five times a second, at random from the actions it was given.

{:ok, session} = Cauldron2D.Net.Load.Session.start_link(url: url, token: token, arena: "pit", kind: :player, actions: ["left", "right", "fire"])
Cauldron2D.Net.Load.Session.report(session)

report/1 returns %{joined: true | false | nil, reason: term, frames: n, recent: n, gap_ms: n, join_ms: n | nil, alive_ms: n}: whether the join has succeeded (nil while pending), the reason of a refusal or a closed connection, the frames received altogether and since the last report, the longest wait between two frames since the last report in milliseconds, how long the join took, and how long the session has been in the arena.

Summary

Functions

Returns a specification to start this module under a supervisor.

How the session is doing, and reset its recent frame count and longest gap.

Start a session; :url, :token, :arena (its id as it writes), :kind (:player or :watcher) and :actions are required, :topic is the channel's prefix (default "world"), :audio :personal (default) or :off to ask the server for no sound.

Leave the arena and stop.

Types

report()

@type report() :: %{
  joined: boolean() | nil,
  reason: term(),
  frames: non_neg_integer(),
  recent: non_neg_integer(),
  gap_ms: non_neg_integer(),
  join_ms: non_neg_integer() | nil,
  alive_ms: non_neg_integer()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

report(session)

@spec report(GenServer.server()) :: report()

How the session is doing, and reset its recent frame count and longest gap.

start_link(opts)

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

Start a session; :url, :token, :arena (its id as it writes), :kind (:player or :watcher) and :actions are required, :topic is the channel's prefix (default "world"), :audio :personal (default) or :off to ask the server for no sound.

stop(session)

@spec stop(GenServer.server()) :: :ok

Leave the arena and stop.