net_backend

API reference

Chat flows

Public room, live:

  1. GET /v1/chat/rooms (HTTP) to show the public rooms (key, name, member_count).
  2. Open the WebSocket and authenticate (auth → auth.ok).
  3. chat.join {"room":"world"} → RoomInfo (keep its id).
  4. chat.history {"room":12,"limit":50} → the latest messages (newest first: reverse for display).
  5. chat.send {"room":12,"text":"hello","nonce":"k3j9x"} → {"message_id":981,"sent_at":…}; then your own chat.message push with id: 981 arrives.
  6. Show every chat.message push for the room; remove messages on chat.deleted; update the online list on chat.presence (or ask chat.members).
  7. After a reconnect: chat.join again, then load history newer than the last message you have (page with chat.history until you reach a known id).

Direct messages:

  1. POST /v1/chat/dm {"user":77} → RoomInfo with kind: "dm", peer: 77 (the same room every time for the same pair).
  2. chat.send {"room":<dm room id>,"text":"…"}: no join needed; both players receive chat.message on every open connection.
  3. GET /v1/chat/dms lists the caller's DM rooms, newest activity first; history works as for any room.

Older history: pass the previous page's next_cursor as cursor (HTTP query or WebSocket data) until next_cursor is absent. Messages are kept 30 days by default.

Moderation: DELETE /v1/chat/rooms/{room}/messages/{message} by the sender or a moderator; the room gets chat.deleted.

Do not resend chat.send automatically after a reconnect: it could post a message twice. If the answer was lost, look for your nonce in the history first.

Generated from API.md (repository commit e25edb9, file sha256 3db87f7bba70).