Two people are typing in the same chat and one is on a train. What arrives, in what order, and what do you store?
Chat ordering with offline clients separates ephemeral typing indicators from durable messages. Messages need a server-assigned per-conversation sequence and a client-generated id for deduplication, so reconnecting phones replay outboxes without duplicates.
Answer
Short answer
For chat ordering with offline clients, never store typing indicators; treat them as expiring hints. Store messages with a server-assigned sequence per conversation for transcript order and a client-generated id for retry deduplication. A reconnecting phone replays its outbox, the server returns existing sequence numbers for duplicates, and clients sync from their last seen sequence.
Was this answer helpful?
Likely follow-ups
- The two participants send messages in the same millisecond to different regional servers. What decides which sequence number each gets?
- A user edits a message that a recipient has already read. What do you store, and what does the recipient see?
- How would you show "delivered" without writing a row per message per recipient?
- A client's outbox holds forty queued messages after a long flight. What order do you send them in, and what do you do if the tenth is rejected?
Related questions
- Usage records arrive duplicated, late and out of order, and the tariff changed in the middle of the month. How does mediation and rating cope?hardAlso on deduplication6 min
- A driver spends part of the day with no mobile signal. How do you design the app so the round still works?hardAlso on offline-first5 min
- How do you leverage WorkManager to guarantee execution, handle conflict resolution, and optimise battery usage in an offline-first Android application requiring bidirectional synchronisation?hardAlso on offline-first3 min
- Every message must survive the phone being wiped, and a user has 40,000 of them. Where do they live and how are they paged?hardAlso on chat6 min