View Source Barytherium.Network (barytherium v0.2.0)
Responsible for coordinating Sender and Receiver. Note that when started, this will immediately (and asynchronously) try to connect to the given host and port.
When the connection succeeds or fails, Network will cast a message to the callback handler,
either:
{:barytherium, :connect, {:ok, pid()}}
or:
{:barytherium, :connect, {:error, atom()}}
For a successful connection, the pid is for the sender, and this is where you should send
a connect frame. For a failed connection, the atom is the error returned by the underlying
network driver (e.g. :nxdomain
, :econnrefused
, etc).
This module makes use of Barytherium.Network.Receiver
and Barytherium.Network.Sender
,
see those modules' docs for information about the messages they send.
This genserver relays {:barytherium, :disconnect, atom()}
messages from Sender and Receiver
and ensures that duplicates won't be sent. Note that this does introduce a race condition
which could potentially obscure the actual cause of the disconnect.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for GenServer.handle_continue/2
.
Callback implementation for GenServer.init/1
.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Callback implementation for GenServer.handle_continue/2
.
Callback implementation for GenServer.init/1
.
start_link(callback_handler, host, port, opts \\ %{}, link_opts \\ [])
View Source@spec start_link( pid(), binary() | [char()] | :inet.ip_address(), :inet.port_number(), map(), [tuple()] ) :: {:ok, pid()}