libero/push
Server-side push support.
Allows the server to send MsgFromServer messages to connected WebSocket clients without a prior request. Uses BEAM pg (process groups) for topic-based subscriptions.
Import this module only if your app needs server push. If unused, no processes or groups are created.
Values
pub fn init() -> Nil
Ensure the push pg scope is started. Call once at server boot. Idempotent — safe to call multiple times.
pub fn join(topic topic: String) -> Nil
Subscribe the calling process to a topic for broadcast pushes.
The process will receive {libero_push, BitArray} messages
when send_to_clients is called for this topic.
pub fn register(client_id client_id: String) -> Nil
Register the calling process with a unique client ID.
Used for targeted pushes via send_to_client.
Typically called in the WebSocket on_init with a session-derived ID.
pub fn send_to_client(
client_id client_id: String,
module module: String,
msg msg: a,
) -> Nil
Send a message to a specific client by ID.
pub fn send_to_clients(
topic topic: String,
module module: String,
msg msg: a,
) -> Nil
Send a message to all clients subscribed to a topic.
pub fn unregister(client_id client_id: String) -> Nil
Unregister the calling process from a client ID.