Skip to main content

Offline Messages

WuKongIM adopts a read-diffusion model. What are read-diffusion and write-diffusion? Reference article: Link After enabling the recent conversation configuration, WuKongIM maintains a recent conversation list for each user on the server side.
  1. When an application goes from offline to online, it needs to synchronize the recent conversation list, as shown in the diagram below:
Offline Message Sync Process
  1. After the application comes online, the application should maintain the recent conversation list online.
  2. When clicking on a conversation (channel) to enter the chat interface, you need to synchronize the messages of that conversation (channel), as shown in the diagram below (at the same time, you need to clear the unread count of the recent conversation using /conversations/setUnread):
Conversation Message Sync

Offline Message Processing Flow

1. Application Startup Process

When your application starts up and the user comes online, follow this process:

2. Message Synchronization Process

When entering a specific conversation:

Implementation Best Practices

1. Conversation List Management

Sync Recent Conversations on Startup:

2. Message History Synchronization

Load Messages When Entering Chat:

3. Real-time Updates

Handle Real-time Message Updates:

API Integration Examples

Using WuKongIM APIs

1. Get Recent Conversations:
2. Get Channel Messages:
3. Clear Unread Count:

Performance Optimization

1. Incremental Synchronization

Use version-based incremental sync to reduce data transfer:

2. Pagination for Large Conversations

Implement pagination for conversations with many messages:

Error Handling

Robust Sync Error Handling

Best Practices Summary

  1. Always sync conversations on app startup to get the latest state
  2. Use incremental sync with version numbers to optimize performance
  3. Clear unread counts when users view conversations
  4. Handle real-time updates properly based on current user context
  5. Implement proper error handling with retry mechanisms
  6. Use pagination for large message histories
  7. Cache data locally to improve user experience during network issues