Internal facade for the built-in WhatsApp session engine.
The GenServer implementation lives in ExWapp.Session.Worker. This module is
used by ExWapp.Client.Transport.Session; it is documented for maintainers
and custom transport authors, but it is not part of ExWapp's stable public
API. Applications should use the %ExWapp.Client{} API through ExWapp.
Summary
Functions
Flushes the session store and exports its complete local snapshot.
Gets one contact from the session store, or nil when it is unknown.
Lists contacts currently present in the session store.
Requests an eight-character phone-number pairing code.
Asks the sender's phone to re-upload an expired media object.
Sends a canonical outbound message through the session engine.
Refreshes contact-related app-state data from the server.
Types
Functions
@spec archive_chat(GenServer.server(), String.t()) :: :ok | {:error, term()}
@spec child_spec(term()) :: Supervisor.child_spec()
@spec connect(GenServer.server()) :: :ok
@spec create_contact(GenServer.server(), String.t(), String.t()) :: :ok | {:error, term()}
@spec delete_chat(GenServer.server(), String.t()) :: :ok | {:error, term()}
@spec delete_contact(GenServer.server(), String.t()) :: :ok | {:error, term()}
@spec disconnect(GenServer.server()) :: :ok
@spec download_media(GenServer.server(), ExWapp.Media.Ref.t(), keyword()) :: {:ok, ExWapp.Media.Download.t()} | {:error, term()}
@spec export_snapshot(GenServer.server()) :: {:ok, map()} | {:error, term()}
Flushes the session store and exports its complete local snapshot.
The result includes decoded :data, the serialized :blob, and a SHA-256
:checksum. This is useful for backups or wrapper-level database imports.
It reflects local state only and does not request additional server history.
@spec flush_store(GenServer.server()) :: :ok | {:error, term()}
@spec get_chat_info(GenServer.server(), String.t()) :: {:ok, ExWapp.Chat.chat()} | {:error, :not_found}
@spec get_contact(GenServer.server(), String.t()) :: ExWapp.Contact.t() | nil
Gets one contact from the session store, or nil when it is unknown.
@spec get_session_id(GenServer.server()) :: term() | nil
@spec health_status(GenServer.server()) :: map()
@spec list_contacts(GenServer.server()) :: [ExWapp.Contact.t()]
Lists contacts currently present in the session store.
@spec message_stream(GenServer.server()) :: Enumerable.t()
@spec pause_sends(GenServer.server()) :: :ok
@spec policy_status(GenServer.server()) :: map()
@spec qr_stream(GenServer.server()) :: Enumerable.t()
@spec request_pairing_code(GenServer.server(), String.t(), keyword()) :: {:ok, String.t()} | {:error, term()}
Requests an eight-character phone-number pairing code.
Call this after connect/1, once the Noise transport has entered the
handshaking state. :custom_code may be supplied and must contain exactly
eight bytes.
@spec resume_sends(GenServer.server()) :: :ok
@spec retry_media(GenServer.server(), String.t(), keyword()) :: {:ok, ExWapp.Media.Ref.t()} | {:error, term()}
Asks the sender's phone to re-upload an expired media object.
The message must still exist in the local message store so its media key and conversation envelope can be authenticated on the wire.
@spec runtime_config(GenServer.server()) :: map()
@spec send_app_state(GenServer.server(), map()) :: {:ok, map(), map()} | {:error, term()}
@spec send_audio(GenServer.server(), binary(), ExWapp.Media.source(), keyword()) :: {:ok, String.t()} | {:error, term()}
@spec send_document(GenServer.server(), binary(), ExWapp.Media.source(), keyword()) :: {:ok, String.t()} | {:error, term()}
@spec send_event( GenServer.server(), binary(), String.t(), integer() | DateTime.t(), keyword() ) :: {:ok, String.t()} | {:error, term()}
@spec send_image(GenServer.server(), binary(), ExWapp.Media.source(), keyword()) :: {:ok, String.t()} | {:error, term()}
@spec send_message(GenServer.server(), ExWapp.Message.t()) :: {:ok, String.t()} | {:error, term()}
Sends a canonical outbound message through the session engine.
The message ID, when present, is preserved through encryption and transport.
@spec send_typing(GenServer.server(), binary(), boolean()) :: :ok | {:error, term()}
@spec start_link(keyword() | ExWapp.Session.Options.t()) :: GenServer.on_start()
@spec state(GenServer.server()) :: status()
@spec stats(GenServer.server()) :: map()
@spec stop_worker(GenServer.server()) :: :ok
@spec subscribe_qr(GenServer.server()) :: {:ok, reference()}
@spec sync_contacts(GenServer.server()) :: :ok | {:error, term()}
Refreshes contact-related app-state data from the server.
This operation updates contacts only; it does not request complete chat history.
@spec unarchive_chat(GenServer.server(), String.t()) :: :ok | {:error, term()}
@spec unsubscribe_qr(GenServer.server(), reference()) :: :ok