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

Copy Markdown View Source

Supervised, per-connection runtime for transport, state, events, Signal storage, delayed work, and coordination.

Summary

Functions

Return a child pid by supervisor child id.

Return a host-supervisor child specification for one connection runtime.

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.

Request the phone to resend a placeholder message through the peer-data pipeline.

Send a message through the coordinator-managed send pipeline.

Send an ACK/NACK through the coordinator-managed socket.

Send a failed-decryption retry request through the coordinator-managed socket.

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)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Return a host-supervisor child specification for one connection runtime.

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.

request_placeholder_resend(supervisor, message_key, msg_data \\ nil, opts \\ [])

@spec request_placeholder_resend(GenServer.server(), map(), map() | nil, keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}

Request the phone to resend a placeholder message through the peer-data pipeline.

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_message_ack(supervisor, node, error_code \\ nil)

@spec send_message_ack(
  GenServer.server(),
  BaileysEx.BinaryNode.t(),
  non_neg_integer() | nil
) ::
  :ok | {:error, term()}

Send an ACK/NACK through the coordinator-managed socket.

send_retry_request(supervisor, node, opts \\ [])

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

Send a failed-decryption retry request through the coordinator-managed socket.

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.