Skip to main content

Module realtime

Module realtime 

Source
Expand description

Realtime Community (Concord) subscription, routing, dispatch, and control-follow.

The per-event cryptographic engine (inbound::process_incoming) already lives in core; this module is the realtime plumbing around it — the relay subscription, the pseudonym→channel route maps, the dispatch of typed inbound::IncomingEvents to an InboundEventHandler, and the control/rekey realtime-follow. It is consumed by crate::VectorCore::listen so headless clients (SDK, CLI, bots) get realtime Community delivery through the same handler as DMs.

Functions§

clear
Clear all realtime route/subscription state. Call from swap_session so a swapped-in account can’t read the prior account’s channel keys / banned sets.
dispatch_event
Route an arriving Community event: a CONTROL/REKEY edition triggers a realtime control refresh; any other (message/reaction/edit/delete/presence/typing/webxdc/kick) is opened against its channel via inbound::process_incoming, persisted, and dispatched to handler. session straddles the relay I/O so a mid-flight account swap can’t write into the swapped-in account.
rebuild_routes
Rebuild ONLY the in-memory route maps from the persisted communities, WITHOUT touching the live relay subscription. Refreshes each cached Channel (incl. its banned set) so a received ban/unban takes live effect without a full resubscribe. Returns the pseudonyms + relays a caller also resubscribing needs.
refresh_control
Realtime control-plane follow: walk a re-founding, fold the control plane (banlist/roles/ metadata/invites), follow channel rekeys, then resubscribe at the new pseudonyms if any epoch advanced (else just refresh the route maps so the new banlist takes live effect). Mirrors the Tauri refresh_community_control orchestration over the already-core catch_up_* primitives.
refresh_subscription
(Re)build the Community subscription: rebuild the route maps, then open a single subscription scoped to every held channel/control pseudonym, targeted at the communities’ relays.
subscription_id
The subscription id of the live Community subscription, if any. Lets a notification loop test whether an arriving event belongs to the Community sub.
teardown_local
Tear down a community locally on a received removal (kick/leave/ban), RETAINING the held epoch keys (so a self-scrub republish/erase still works), then refresh the subscription so we stop listening on its pseudonyms. Headless consumers can call this from on_community_self_removed; the GUI does a richer teardown (prune chats/relays + republish the list) in its handler instead.