FixAlchemy.Server.Logon (FIXAlchemy v0.2.0)
View SourceMatching an inbound Logon to one of an acceptor's configured sessions.
An acceptor learns who is calling from the Logon itself, so the first message
on a new connection decides which session the connection becomes, or that it
becomes none and is refused. establish/3 makes that decision and performs no
IO, so it can be exercised on its own.
Comp ids are read from the initiator's point of view: the Logon's
SenderCompID (49) is the session's :target_comp_id, and its TargetCompID
(56) is the session's :sender_comp_id.
Session configuration
Each entry of sessions is a keyword list or map carrying at least
:sender_comp_id and :target_comp_id. Everything else it holds is returned
untouched in match.session, so a caller can put :connection_id,
:handlers or any other per-session setting there.
Declaring :username and :password on a session requires the Logon to
carry matching Username (553) and Password (554). Passing an :authenticate
function in opts replaces that check for every session; it receives the
session and the Logon's fields and returns :ok or {:error, text}.
Summary
Functions
Decide whether a Logon may open a session.
Types
@type match() :: %{ session: session(), heartbeat_interval: pos_integer(), msg_seq_num: pos_integer(), reset_sequence?: boolean() }
Functions
@spec establish([{binary(), binary()}], [session()], keyword()) :: {:ok, match()} | {:reject, binary()}
Decide whether a Logon may open a session.
fields is the Logon as FixAlchemy.Parser.split_fields/1 returns it.
Options
:fix_version- the BeginString the acceptor speaks; when set, a Logon carrying any other is refused:authenticate- a two-argument function replacing credential checking
Returns {:ok, match}, or {:reject, text} carrying the Text (58) to send
in the refusing Logout.