import type { Call } from './calls'; import type { ConversationRead, Message, MessageDeletion, ReactionChange, } from './conversations'; /** * Events the API pushes over the socket. Changes are always made with an * HTTP request; the socket only tells the other tabs and people about them. */ export interface ServerToClientEvents { /** * A message was posted in a conversation or cauldron the user can read * (their own messages too). `realmId` is set for a cauldron's message. */ 'message:created': ( message: Message, context: { realmId: string | null }, ) => void; /** * A message the user can read was deleted, by its author or by someone * who looks after the place. */ 'message:deleted': (deletion: MessageDeletion) => void; /** * Someone added or took back a reaction on a message the user can read. * It carries the new count, so applying it twice does no harm. */ 'reaction:changed': (change: ReactionChange) => void; /** * The user read a conversation or cauldron somewhere (this tab included): * its unread count is now this. */ 'conversation:read': (read: ConversationRead) => void; /** * Someone joined or left the call in a conversation or cauldron the user * can read. No participants left means the call is over. */ 'call:changed': (call: Call) => void; /** * A realm the user is (or just stopped being) in changed. "details" covers * its name, cauldrons, roles, what the user may do in it and whether they * are still in it: fetch GET /realms and GET /realms/:id again. "members" * is a change to who is in it or which roles they hold: fetch * GET /realms/:id (for the member count) and GET /realms/:id/members. */ 'realm:changed': (realmId: string, what: 'details' | 'members') => void; /** * A conversation the user is (or just stopped being) in was created, * renamed or changed members; fetch GET /conversations again. */ 'conversations:changed': () => void; /** The user's friends or friend requests changed; fetch GET /friends again. */ 'friends:changed': () => void; } /** Nothing yet: clients only listen. */ export type ClientToServerEvents = Record;