Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between smack packet listener and message listener

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?

like image 482
Subhash Sasidharakurup Avatar asked Apr 07 '14 07:04

Subhash Sasidharakurup


2 Answers

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

like image 122
Fallak Asad Avatar answered Nov 17 '22 06:11

Fallak Asad


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.

like image 1
vitalyster Avatar answered Nov 17 '22 04:11

vitalyster