BaileysEx.Connection.Supervisor (baileys_ex v0.1.0-alpha.9)

Copy Markdown View Source

Connection runtime supervisor with rc.9-style socket, store, and event layers.

Summary

Functions

Return a child pid by supervisor child id.

Returns a specification to start this module under a supervisor.

Return the coordinator pid when present.

Return the event emitter pid when present.

Return the {socket_module, socket_pid} transport tuple used by feature helpers.

Request a pairing code through the active socket.

Send a message through the coordinator-managed send pipeline.

Send a status message through the coordinator-managed send pipeline.

Send a WAM analytics buffer through the active socket.

Return the wrapped Signal store for the connection when present.

Start a connection runtime from an auth state payload.

Start the supervisor and its subtree of runtime connection processes.

Stop a running connection runtime.

Return the connection store pid when present.

Subscribe to raw event maps emitted by the connection runtime.

Safely returns the child specifications for the active connection supervisor subtree.

Functions

child_pid(supervisor, child_id)

@spec child_pid(GenServer.server(), term()) :: pid() | nil

Return a child pid by supervisor child id.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

coordinator(supervisor)

@spec coordinator(GenServer.server()) :: pid() | nil

Return the coordinator pid when present.

event_emitter(supervisor)

@spec event_emitter(GenServer.server()) :: pid() | nil

Return the event emitter pid when present.

queryable(supervisor)

@spec queryable(GenServer.server()) :: {module(), pid()} | nil

Return the {socket_module, socket_pid} transport tuple used by feature helpers.

request_pairing_code(supervisor, phone_number, opts \\ [])

@spec request_pairing_code(GenServer.server(), binary(), keyword()) ::
  {:ok, binary()} | {:error, term()}

Request a pairing code through the active socket.

send_message(supervisor, jid, content, opts \\ [])

@spec send_message(GenServer.server(), BaileysEx.JID.t(), map() | struct(), keyword()) ::
  {:ok, map()} | {:error, term()}

Send a message through the coordinator-managed send pipeline.

send_status(supervisor, content, opts \\ [])

@spec send_status(GenServer.server(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}

Send a status message through the coordinator-managed send pipeline.

send_wam_buffer(supervisor, wam_buffer)

@spec send_wam_buffer(GenServer.server(), binary()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}

Send a WAM analytics buffer through the active socket.

signal_store(supervisor)

@spec signal_store(GenServer.server()) :: BaileysEx.Signal.Store.t() | nil

Return the wrapped Signal store for the connection when present.

start_connection(auth_state, opts \\ [])

@spec start_connection(
  term(),
  keyword()
) :: Supervisor.on_start()

Start a connection runtime from an auth state payload.

start_link(opts)

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

Start the supervisor and its subtree of runtime connection processes.

stop_connection(supervisor)

@spec stop_connection(GenServer.server()) :: :ok | {:error, term()}

Stop a running connection runtime.

store(supervisor)

@spec store(GenServer.server()) :: pid() | nil

Return the connection store pid when present.

subscribe(supervisor, handler)

@spec subscribe(GenServer.server(), (map() -> term())) ::
  (-> :ok) | {:error, :event_emitter_not_available}

Subscribe to raw event maps emitted by the connection runtime.

which_children(supervisor)

@spec which_children(GenServer.server()) :: [
  {term(), :restarting | :undefined | pid(), :supervisor | :worker,
   :dynamic | [module()]}
]

Safely returns the child specifications for the active connection supervisor subtree.