YACS

Realtime events

The app keeps a Socket.IO connection to /socket.io, authenticated with the session cookie. On connect, the socket joins a room for its user and one for its device, presence is refreshed, and any calls still ringing for the user are re-sent.

Event names are deliberately short to keep frames small. They're defined in @yacs/dto/events:

import { MessageEvent, EnvelopeEvent } from "@yacs/dto/events";

Most client → server events use Socket.IO acknowledgements to return a result.

Conversations

EventCodeDirectionDescription
ConversationEvent.CREATEvcserver → clientA conversation was created with you (e.g. someone accepted your invite).
ConversationEvent.UPDATEvuserver → clientConversation changed (name, members…).
ConversationEvent.DELETEvdserver → clientConversation removed.

Messages

EventCodeDirectionDescription
MessageEvent.CREATEmcbothNew message.
MessageEvent.UPDATEmubothMessage edited or status changed.
MessageEvent.DELETEmdbothMessage deleted.
MessageEvent.DELETE_ALLmDserver → clientAll messages in a conversation deleted.
MessageEvent.TYPINGmtbothTyping indicator.
MessageEvent.READmrbothRead receipt.

Users

EventCodeDirectionDescription
UserEvent.UPDATEuuserver → clientA contact's name or presence (isOnline, lastSeen) changed.
UserEvent.STATUSusclient → serverReports whether the app is visible ({ active }), which drives presence.

Calls

EventCodeDirectionDescription
CallEvent.MAKEcmserver → clientIncoming call.
CallEvent.ANSWERcabothClient answers a ringing call; the server tells the caller and the callee's other devices it was answered.
CallEvent.DISCONNECTcdbothHang up (client reports duration); the server notifies the other side when a call ends.

Envelopes

Envelopes carry direct-conversation traffic (see Conversations). Payloads are yacs.v1 protobuf messages.

EventCodeDirectionDescription
EnvelopeEvent.SENDesclient → serverRelay an EnvelopeSend (with devices already reached peer to peer).
EnvelopeEvent.RECEIVEeRserver → clientRelayed Envelope.
EnvelopeEvent.SYNCeSclient → serverFetch queued envelopes (EnvelopeBatch).
EnvelopeEvent.ACKeaclient → serverEnvelopeAck — stored envelope IDs to drop from the queue.

Peers & transfers

EventCodeDirectionDescription
PeerEvent.REGISTERprclient → serverRegister this device's PeerJS peer ID.
PeerEvent.LISTplclient → serverList peer IDs of a conversation's other devices.
PeerEvent.RESOLVEpRclient → serverResolve the user/device behind an incoming peer connection from its ticket.
PeerEvent.TRANSFER_OFFERpoclient → serverSender offers a file for transfer from this device.
PeerEvent.TRANSFER_TICKETptclient → serverRecipient gets a signed ticket and the sender's peer ID.
PeerEvent.TRANSFER_VERIFYpvclient → serverSender verifies a recipient's ticket before sending.
PeerEvent.TRANSFER_WITHDRAWpwclient → serverSender withdraws an offer.

Peer tickets are signed by the server, so a device only accepts peer connections and file requests from users it is actually in a conversation with.