Interface MessageInterceptor
-
- All Implemented Interfaces:
public interface MessageInterceptorInterceptor 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
trueto consume the event (no further SDK processing) orfalseto pass it through to the SDK.
-
-
Method Summary
Modifier and Type Method Description abstract booleaninterceptReceivedMessage(Message message, int left, boolean hasPackage, boolean offline)Called when a real-time or offline message is received. abstract booleaninterceptOnSendMessage(Message message)Called before a message is sent. abstract booleaninterceptOnSentMessage(Message message)Called after a message is successfully sent. abstract booleaninterceptOnInsertOutgoingMessage(ChannelType type, String targetId, SentStatus sentStatus, MessageContent content, long sentTime)Called before an outgoing message is inserted into the local database. abstract booleaninterceptOnInsertIncomingMessage(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. -
-
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.
hasPackageindicates whether additional batches remain on the server.leftindicates remaining messages in the current batch after this one.- Offline sync is complete when both
hasPackageandleftare0.
- Parameters:
message- the received messageleft- remaining message count in the current batchhasPackage- whether additional message batches remain on the serveroffline- whether this message is an offline message- Returns:
trueto intercept (SDK will not process further);falseto pass through
-
interceptOnSendMessage
abstract boolean interceptOnSendMessage(Message message)
Called before a message is sent.
- Parameters:
message- the message about to be sent- Returns:
trueto intercept;falseto pass through
-
interceptOnSentMessage
abstract boolean interceptOnSentMessage(Message message)
Called after a message is successfully sent.
- Parameters:
message- the sent message- Returns:
trueto intercept;falseto 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 typetargetId- target channel ID (peer ID for direct, group ID for group, etc.sentStatus- sent status of the messagecontent- message content (e.g.sentTime- sent timestamp from getSentTime- Returns:
trueto intercept;falseto 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 typetargetId- target channel IDsenderId- sender user IDreceivedStatus- received statuscontent- message contentsentTime- sent timestamp- Returns:
trueto intercept;falseto 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 typetargetId- target channel IDsentStatus- sent statuscontent- message contenttime- sent timestampcallback- callback to invoke with the modified message; callonErrorto signal that the message should be blocked- Returns:
trueto intercept;falseto pass through
-
-
-
-