mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 05:51:08 +01:00
Introduce XMPPConnection.add(Message|Presence)Interceptor
add deprecate addStanzaInterceptor().
This commit is contained in:
parent
5db6191110
commit
e2d206e741
24 changed files with 419 additions and 102 deletions
|
|
@ -37,11 +37,11 @@ import org.jivesoftware.smack.chat2.OutgoingChatMessageListener;
|
|||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.FromTypeFilter;
|
||||
import org.jivesoftware.smack.filter.MessageTypeFilter;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
|
||||
|
|
@ -73,7 +73,6 @@ public final class ChatStateManager extends Manager {
|
|||
|
||||
private static final Map<XMPPConnection, ChatStateManager> INSTANCES = new WeakHashMap<>();
|
||||
|
||||
private static final StanzaFilter filter = new NotFilter(new StanzaExtensionFilter(NAMESPACE));
|
||||
private static final StanzaFilter INCOMING_MESSAGE_FILTER =
|
||||
new AndFilter(MessageTypeFilter.NORMAL_OR_CHAT, FromTypeFilter.ENTITY_FULL_JID);
|
||||
private static final StanzaFilter INCOMING_CHAT_STATE_FILTER = new AndFilter(INCOMING_MESSAGE_FILTER, new StanzaExtensionFilter(NAMESPACE));
|
||||
|
|
@ -117,13 +116,13 @@ public final class ChatStateManager extends Manager {
|
|||
ChatManager chatManager = ChatManager.getInstanceFor(connection);
|
||||
chatManager.addOutgoingListener(new OutgoingChatMessageListener() {
|
||||
@Override
|
||||
public void newOutgoingMessage(EntityBareJid to, Message message, Chat chat) {
|
||||
public void newOutgoingMessage(EntityBareJid to, MessageBuilder message, Chat chat) {
|
||||
if (chat == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if message already has a chatStateExtension, then do nothing,
|
||||
if (!filter.accept(message)) {
|
||||
if (message.hasExtension(ChatStateExtension.NAMESPACE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue