Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Building 1:1 chat

A 1:1 chat thread connects two user IDs over WebSocket: load history when opening the thread, send new messages with send(), and append live deliveries from onMessage.


Thread model

  User A (user-alice)                         User B (user-bob)
         β”‚                                           β”‚
         β”‚  fetchChatHistory([bob]) on open          β”‚
         β”‚  send({ receiverId: "user-bob" })         β”‚
         β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
         β”‚                                           β”‚
         │◄───────────────────────────────────────────
         β”‚         onMessage on both sides            β”‚
  • Thread key β€” pair (userA, userB); your app defines sort order for fetchChatHistory

  • Same appId β€” both participants use the same DNotifier application

  • Stable userId β€” map your auth user to a consistent DNotifier id


Implementation checklist

  1. Connect on login β€” transport: "ws", userId = authenticated user

  2. Open thread β€” call fetchChatHistory({ senderId, receiverIds: [peerId] })

  3. Render history β€” handle history response in onMessage

  4. Send message β€” send({ senderId, receiverId, data: { type: "text", text } })

  5. Live updates β€” append onMessage payloads to the thread view

  6. Reconnect β€” refetch history after disconnect to fill gaps


Message payload convention

Extend with image, audio, doc for rich chat β€” see Structured payloads.


Language guides

Language
Guide

JavaScript / TypeScript

Dart / Flutter


Topic
Link

Chat history

Save history

UI patterns

Last updated