Skip to content

The protocol

The browser talks to the servers two ways:

  • HTTP for logon, accounts, settings, uploads and push notification settings.
  • One Socket.IO connection for everything live: presence, messages, games, calls, mail.

Every payload in both directions is a Zod schema in @retro/protocol. The server parses every request before a handler sees it.

A call goes from the browser to the server and always gets an answer:

{ ok: true, data } | { ok: false, error: { code, message } }

CALLS in packages/protocol/src/api.ts is the list, one schema per call, and CallResults gives each answer. Names are area:action, such as message:send or call:join.

The server sends one event channel carrying the ServerEvent union from packages/protocol/src/messenger.ts. A message event is also echoed to the sender’s other windows.

  • session:start starts Messenger on a connection. Until then the connection doesn’t count for presence.
  • Calls are rate limited per connection and per account across every server node.
  • An error’s message is safe to show to the person.

The protocol-change checklist lists every file a new call or event touches.