6

Hi I am creating an android app as a XMPP client to an ejabbered server.

But I am really confused because I saw I can send messages as apacket or messages also I can receive messages using PacketListener and MessageListener.

Whats the difference between PacketListener and MessageListener and which is the good way to receive messages? Using packet listener or message listener?

Ion Aalbers
  • 7,830
  • 3
  • 37
  • 50

2 Answers2

5

MessageListener only listen for the packets related to messages while PacketListener listen for the all kinds of packets that may include message related packets, subscription related packets, invitation related packets, it may listen for the all xml packets send by the server if no filter is applied. You may also add filter to filter specific packets. it is also used for process custom packets and writing custom XMPP extensions

Fallak Asad
  • 368
  • 4
  • 18
1

MessageListener is a high-level interface just to deal with messages, PacketListener is more complex "tool" to match and process custom packets and writing custom XMPP extensions. If MessageListener suitable for your needs - just use them.

vitalyster
  • 4,980
  • 3
  • 19
  • 27