Interaction Subscribers Overview
EdgeInteract has two distinct subscriber roles: the interaction receiver (the targeted user's client, which receives and renders interaction requests) and the callback subscriber (the server code that receives the response). Understanding both roles is essential.
Two Subscriber Roles
Interaction Receiver
The targeted user's browser. Subscribes to interactions.{userId}. Receives InteractionRequest messages. Renders UI components. Publishes InteractionResponse.
Implemented by: InteractionSubscriber (client package), useInteractionReceiver() (React)
Callback Subscriber
The server code that sent the request. Subscribes to interactions.callback.{interactionId}. Receives InteractionResponse or InteractionTimeout. Resumes the workflow.
Implemented by: InteractionPipeline (server package), internal to PublishAndWaitAsync()
Subscription Topics
| Topic | Subscriber | Messages Received |
|---|---|---|
interactions.{userId} | User's browser session(s) | InteractionRequest |
interactions.callback.{interactionId} | Server (the pipeline) | InteractionResponse, InteractionTimeout |
interactions.ack.{interactionId} | User's browser session | InteractionAck |
interactions.dismiss.{userId} | User's browser session(s) | Dismissal signals (timeout, first-to-respond) |
Subscription Lifecycle
Client Connects
User logs in. InteractionProvider mounts. InteractionSubscriber subscribes to interactions.{userId} and interactions.dismiss.{userId} via EdgeStream.
Pending Interactions Delivered
Any pending interactions (published while the user was offline) are delivered immediately on connection. The client renders them in the interaction queue.
Live Interactions Arrive
New interactions arrive in real-time via the EdgeStream subscription. They are added to the queue as they arrive.
User Responds
For each interaction, the user acts. InteractionResponsePublisher publishes to the callback topic. The ack topic subscription is created transiently for this interaction.
Client Disconnects
On disconnect or unmount, InteractionProvider unsubscribes from all interaction topics. In-flight interactions are preserved server-side and re-delivered on reconnect.
InteractionProvider sets up and tears down all required subscriptions automatically. Use the React hooks to access the data.