logo
On this page

What is the difference between the onRoomAttributesUpdated callback and the onRoomAttributesBatchUpdated callback in ZIM SDK? When are they triggered respectively?

2025-09-25
Products / Plugins:In-app chat
Platform / Framework:iOS / Android / macOS / Windows / Web / Mini Program / Electron / ReactNative / Unity3D

Callback Differences

Both callbacks are used to receive update notifications for room attributes (key-value). The core difference is whether the operation types included in a single update operation are uniform.

Callback NameTrigger ScenarioParameter Characteristics
onRoomAttributesUpdatedIn a single update, all key-value changes are of the same operation type (all additions/modifications or all deletions)The ZIMRoomAttributesUpdateInfo carried in the callback has the action field clearly defined as add (add or modify key-value) or delete (delete key-value), containing only the update information of this single operation type
onRoomAttributesBatchUpdatedIn a single update, both operation types are included (both added/modified key-values and deleted key-values)The callback carries List<ZIMRoomAttributesUpdateInfo>, the list must contain two elements: one update information with action as add, and one with action as delete, corresponding to the specific content of the two operations respectively
  1. Initialize listening: First register both onRoomAttributesUpdated and onRoomAttributesBatchUpdated callbacks to ensure no update notifications are missed.
  2. Full-scale baseline query: Query the full data of room attributes through the queryRoomAttributes interface, store the results in memory as the initial baseline value.
  3. Incremental update merge:
    • When receiving onRoomAttributesUpdated, based on the action (add/delete) in the callback, directly perform the corresponding operation (add/modify or delete key-value) on the full data in memory.
    • When receiving onRoomAttributesBatchUpdated, traverse the two ZIMRoomAttributesUpdateInfo in the list, merge the memory data according to add and delete actions respectively, and finally keep the memory data consistent with the actual room attributes.

Previous

What is the difference between the onConnectionStateChanged callback and the onRoomStateChanged callback in ZIM SDK? When are they triggered respectively?

Next

When the Web platform reports an error "https or localhost required", is "https" mandatory?

On this page

Back to top