0
votes

I would like to know if it is possible to decide when consume a menssage from a xmmp server ?

Let me try to explain better... Imagine that i developed a bot to read all messages that the body of the message start with" MESSAGETOBOTONLY: " if i do the usual method to read a message:

public void processMessage(Chat chat, Message message) {
    if (message.getType() == Message.Type.chat) { ... }
} 

All messages i received will be consumed and lost... What i want is just to consume messages that start with: " MESSAGETOBOTONLY: " and let the other messages still on server to be consumed by a xmpp chat client.

best regards,

1

1 Answers

1
votes

Don't abuse magic strings within a messages body element to indicate a special message type.

If you want to control a bot then use IQ packets or add an extra extension to the message type packet to indicate that this message serves a special purpose. Then you could add a packetListener with a packetFilter to get notified if these types of XMPP stanzas are received.