Interface MessageInterceptor

  • All Implemented Interfaces:

    
    public interface MessageInterceptor
    
                        

    Interceptor for message send and receive operations.

    Register an implementation via ai.nexconn.chatui.config.FeatureConfig to intercept outgoing and incoming messages before the SDK processes them.

    All intercept methods return true to consume the event (no further SDK processing) or false to pass it through to the SDK.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract boolean interceptReceivedMessage(Message message, int left, boolean hasPackage, boolean offline) Called when a real-time or offline message is received.
      abstract boolean interceptOnSendMessage(Message message) Called before a message is sent.
      abstract boolean interceptOnSentMessage(Message message) Called after a message is successfully sent.
      abstract boolean interceptOnInsertOutgoingMessage(ChannelType type, String targetId, SentStatus sentStatus, MessageContent content, long sentTime) Called before an outgoing message is inserted into the local database.
      abstract boolean interceptOnInsertIncomingMessage(ChannelType type, String targetId, String senderId, MessageReceivedStatusInfo receivedStatus, MessageContent content, long sentTime) Called before an incoming message is inserted into the local database.
      boolean )>interceptOnInsertOutgoingMessage(ChannelType type, String targetId, SentStatus sentStatus, MessageContent content, long time, OperationHandler<Message> callback) Called before an outgoing message is inserted, with an optional result callback.
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • interceptReceivedMessage

         abstract boolean interceptReceivedMessage(Message message, int left, boolean hasPackage, boolean offline)

        Called when a real-time or offline message is received.

        Offline message batching notes:

        • The server packs up to 200 messages per batch.
        • hasPackage indicates whether additional batches remain on the server.
        • left indicates remaining messages in the current batch after this one.
        • Offline sync is complete when both hasPackage and left are 0.
        Parameters:
        message - the received message
        left - remaining message count in the current batch
        hasPackage - whether additional message batches remain on the server
        offline - whether this message is an offline message
        Returns:

        true to intercept (SDK will not process further); false to pass through

      • interceptOnSendMessage

         abstract boolean interceptOnSendMessage(Message message)

        Called before a message is sent.

        Parameters:
        message - the message about to be sent
        Returns:

        true to intercept; false to pass through

      • interceptOnSentMessage

         abstract boolean interceptOnSentMessage(Message message)

        Called after a message is successfully sent.

        Parameters:
        message - the sent message
        Returns:

        true to intercept; false to pass through

      • interceptOnInsertOutgoingMessage

         abstract boolean interceptOnInsertOutgoingMessage(ChannelType type, String targetId, SentStatus sentStatus, MessageContent content, long sentTime)

        Called before an outgoing message is inserted into the local database.

        Parameters:
        type - channel type
        targetId - target channel ID (peer ID for direct, group ID for group, etc.
        sentStatus - sent status of the message
        content - message content (e.g.
        sentTime - sent timestamp from getSentTime
        Returns:

        true to intercept; false to pass through

      • interceptOnInsertIncomingMessage

         abstract boolean interceptOnInsertIncomingMessage(ChannelType type, String targetId, String senderId, MessageReceivedStatusInfo receivedStatus, MessageContent content, long sentTime)

        Called before an incoming message is inserted into the local database.

        Parameters:
        type - channel type
        targetId - target channel ID
        senderId - sender user ID
        receivedStatus - received status
        content - message content
        sentTime - sent timestamp
        Returns:

        true to intercept; false to pass through

      • interceptOnInsertOutgoingMessage

         boolean )>interceptOnInsertOutgoingMessage(ChannelType type, String targetId, SentStatus sentStatus, MessageContent content, long time, OperationHandler<Message> callback)

        Called before an outgoing message is inserted, with an optional result callback.

        Use this overload when you need to return an asynchronous result via the callback — for example, to attach custom metadata to an image message before insertion.

        Parameters:
        type - channel type
        targetId - target channel ID
        sentStatus - sent status
        content - message content
        time - sent timestamp
        callback - callback to invoke with the modified message; call onError to signal that the message should be blocked
        Returns:

        true to intercept; false to pass through