Platform

Live Events and Presence on Calimero Network

Stream changes to the right people, without logging every cursor

Two kinds of realtime: events, which are part of the committed log and reach only their audience, and presence, which is fast, short-lived and never written down.

Live Events and Presence on Calimero Network

Key takeaways

  • Apps emit typed events with an audience. They're delivered only after the write commits.
  • Clients follow events over server-sent events from any log index, so they miss nothing and see nothing twice.
  • Presence (cursors, who's online) is kept in node memory, expires after 7 seconds and is never logged.

How do events work?

An app declares its events as an #[app::event] enum, and they're listed in the app's ABI. A method emits one with env::emit(event, audience). The event is part of the call's outcome, so it exists only if the call succeeds and commits.

Every event has an audience, such as everyone subscribed to the app or a specific set of accounts. The node resolves the audience when it delivers, against the organization as it is at that moment. A person removed from a team stops receiving that team's events.

How does a client subscribe?

Clients follow GET /apps/{app}/events?from=N, a server-sent events stream. It sends the committed events from log index N, then live ones, each only to the accounts in its audience. Each app keeps its last 10,000 events.

A client that renders a view and then follows the stream passes the view's index plus one. That way it misses nothing and sees nothing twice. To make another app react, use a cross-app call rather than an event: events are for clients.

What is presence, and why isn't it logged?

Presence answers "who has this document open, and where is their cursor?" It changes many times a second, so writing it to a replicated log would be wasteful. Instead, each device posts its current state (up to 4 KiB). Every node keeps the latest state from each device in memory and passes it to the others.

  • A device that stops sending heartbeats for 7 seconds disappears, and streams see it leave.
  • An app can track up to 512 devices. A new one evicts the one heard from longest ago.
  • A node serves up to 4,096 event and presence streams.

Presence is best effort by design. It's never in a log or a receipt, so use events for anything that needs to be provable.

Frequently asked questions

Does Calimero Network use WebSockets?

Events and presence are delivered as server-sent events, from GET /apps/{app}/events and GET /apps/{app}/presence/stream.

Can someone outside the audience see an event?

No. Each event is sent only to the accounts its audience names, resolved against the organization at delivery time.

Is presence stored anywhere?

No. It lives in node memory, expires 7 seconds after the last heartbeat, and never enters the log or any receipt.

← All postsAll use cases →

Read it, then run it.

Start free on Calimero Network Cloud, or book a demo with the team.