Serve a game over ssh, with its accounts, its web endpoint and its beacon.
{:ok, server} = Cauldron2D.Drafter.Server.start(game: MyGame.Client, port: 2222, web: {:my_game, MyGame.Web.Endpoint, 2280})
Cauldron2D.Drafter.Server.stop(server)Players register on first connection as new@host (:register_as), or through
whatever login the game's web pages offer. Each account is given its own sound
port on the server — :sound_port for the first account, the next number for the
next, and so on — kept in its props as :pulse_port; the terminal client's audio
goes as raw PCM through the ssh -R <port>:127.0.0.1:4713 tunnel to a player
program on the player's machine. The worlds are the game's, registered with
Cauldron2D.Worlds before or after the server starts.
Options
:game— the module implementingCauldron2D.Client.Game. Required:port— the ssh port,0for any free one. Default2222:ip— what to bind, asDrafter.Server.start_ssh/2takes it. Default:any:accounts— the account file, or a runningDrafter.Accountsserver. DefaultCauldron2D.Paths.data(atlas, "accounts.terms"):accounts_name— a name for the accounts server it starts. Default none:sound_port— the first account's sound port,falsefor none. Default24713:system_dir— the ssh host key directory. Default: drafter's temporary keys:register_as— the name that registers. Default"new":mount_props— merged into every session's mount props. Default%{}:send_buffer— the bytes of each connection's send buffer (Drafter.Server.start_ssh/2), so a session drawing faster than its connection carries skips frames instead of falling behind. Default65536:login_timeout— the milliseconds a player has from connecting to logging in, ssh's host key question and the password included. Default600000:web—{otp_app, endpoint, port}: the game's Phoenix endpoint, started on every IPv4 interface at that port. Default: none:beacon— call on the local network withCauldron2D.Beacon. Defaulttrue:beacon_port— its port. DefaultCauldron2D.Beacon.port/0:node— name this VM so other nodes can join its worlds,falsefor none. Default<atlas>@<host>, when the VM is not already named
Returns {:ok, %{daemon, port, accounts, http, node, beacon}}, port the ssh port
served on; stop/1 stops what was
started, leaving the worlds registered.
Summary
Functions
This machine's name, as players are told to connect to it.
Start serving; see the module documentation for the options.
Stop what start/1 started. Returns once the ssh port, the web endpoint and the
beacon are stopped, so the port can be served on again at once. Then, from a process
of its own, each player connected over ssh is disconnected — their game left, their
terminal restored and notice shown on it (default "The server closed this session.") — and the
accounts server is stopped; the caller may be a process those players' games call.
Types
@type t() :: %{ daemon: pid() | [pid()], port: pos_integer(), accounts: pid(), http: pos_integer() | nil, node: node() | nil, beacon: pid() | nil, web: module() | nil }
Functions
@spec hostname() :: String.t()
This machine's name, as players are told to connect to it.
Start serving; see the module documentation for the options.
Stop what start/1 started. Returns once the ssh port, the web endpoint and the
beacon are stopped, so the port can be served on again at once. Then, from a process
of its own, each player connected over ssh is disconnected — their game left, their
terminal restored and notice shown on it (default "The server closed this session.") — and the
accounts server is stopped; the caller may be a process those players' games call.