Package io.rong.imlib

Class IRongCoreListener.OnReceiveMessageWrapperListener

  • All Implemented Interfaces:
    io.rong.imlib.IRongCoreListener.OnReceiveMessageListener

    
    public abstract class IRongCoreListener.OnReceiveMessageWrapperListener
     implements IRongCoreListener.OnReceiveMessageListener
                        

    Listener for receiving messages. Note: Switch threads to handle time-consuming operations.

    This interface can replace 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final boolean onReceived(Message message, int left) Handles received messages.
      boolean onReceived(Message message, ReceivedProfile profile)
      abstract boolean onReceived(Message message, int left, boolean hasPackage, boolean offline) Receives real-time or offline messages.
      void onOfflineMessageSyncCompleted() Offline message reception completed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IRongCoreListener.OnReceiveMessageWrapperListener

        IRongCoreListener.OnReceiveMessageWrapperListener()
    • Method Detail

      • onReceived

         final boolean onReceived(Message message, int left)

        Handles received messages.

        Parameters:
        message - The received message object.
        left - The number of remaining messages to be fetched.
        Returns:

        Indicates whether the message processing is completed.

      • onReceived

         boolean onReceived(Message message, ReceivedProfile profile)
      • onReceived

         abstract 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, returns false for the SDK to handle.

      • onOfflineMessageSyncCompleted

         void onOfflineMessageSyncCompleted()

        Offline message reception completed. Remote message synchronization completed callback, triggered once upon each successful connection. If there are no remote messages, it will be triggered immediately after the connection is successful. If there are a large number of historical messages on the remote side, it will wait until the message reception is completed before triggering. Added in @5.2.3