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 Name | Trigger Scenario | Parameter Characteristics |
|---|---|---|
| onRoomAttributesUpdated | In 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 |
| onRoomAttributesBatchUpdated | In 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 |
Recommended Processing Flow
- Initialize listening: First register both
onRoomAttributesUpdatedandonRoomAttributesBatchUpdatedcallbacks to ensure no update notifications are missed. - Full-scale baseline query: Query the full data of room attributes through the
queryRoomAttributesinterface, store the results in memory as the initial baseline value. - 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.
- When receiving
