Class OnReceiveMessageWrapperListener
-
- All Implemented Interfaces:
-
io.rong.imlib.IRongCoreListener.OnReceiveMessageListener
public abstract class OnReceiveMessageWrapperListener extends IRongCoreListener.OnReceiveMessageWrapperListener
Listener for receiving messages.
This interface can replace IRongCoreListener.OnReceiveMessageListener to address the issue of frequent UI refreshes when receiving a large number of messages. The interface returns the `left` and `hasPackage` parameters, which can be used together to determine when all offline messages have been fetched.
-
-
Constructor Summary
Constructors Constructor Description OnReceiveMessageWrapperListener()
-
Method Summary
Modifier and Type Method Description abstract void
onReceivedMessage(Message message, ReceivedProfile profile)
Receives real-time or offline messages. boolean
onReceived(Message message, int left, boolean hasPackage, boolean offline)
Receives real-time or offline messages. -
-
Method Detail
-
onReceivedMessage
abstract void onReceivedMessage(Message message, ReceivedProfile profile)
Receives real-time or offline messages. Note: Switch threads to handle time-consuming operations.
- Parameters:
message
- The received message objectprofile
- ReceivedProfile, which stores left (After the client successfully connects, the server will deliver all compensation messages in packages to the client, with a maximum of 200 messages per package.
-
onReceived
boolean onReceived(Message message, int left, boolean hasPackage, boolean offline)
Receives real-time or offline messages.
Note: 1. For offline messages, the server packages 200 messages into a single bundle and sends it to the client, which then parses the bundle. 2. `hasPackage` indicates whether there are remaining message bundles, and `left` indicates how many messages are left in the current bundle after parsing and delivering them to the app layer. How to determine if all offline messages have been received: 1. Both `hasPackage` and `left` are 0; 2. `hasPackage` being 0 indicates that the client is receiving the last bundle (200 messages), and `left` being 0 indicates that the last message in the final bundle has been received.
- Parameters:
message
- The received message object.left
- When the client successfully connects, the server sends all compensation messages in bundles, with a maximum of 200 messages per bundle (i.e., a Package).hasPackage
- Indicates whether there are undelivered message bundles on the server.offline
- Indicates whether the message is an offline message.- Returns:
Whether the message was processed. Returns
true
if the app processed the message; otherwise, returnsfalse
for the SDK to handle.
-
-
-
-