Created
January 26, 2022 11:24
-
-
Save ankanch/2fe307b97058ebcd8e582d1db28c9df3 to your computer and use it in GitHub Desktop.
print jicofo stanza?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// step 1. writing a class like below: | |
import org.jivesoftware.smack.StanzaListener; | |
import org.jivesoftware.smack.packet.Presence; | |
import org.jivesoftware.smack.packet.Stanza; | |
public class PrintStanzaHandler implements StanzaListener { | |
@Override | |
public void processStanza(Stanza stanza) { | |
if(stanza instanceof Presence) | |
{ | |
logger.debug(String.format("stanza= %s", stanza.toXML().toString())); | |
} | |
} | |
} | |
// step 2. get your xmpp connection , add this listener | |
getConnection().addAsyncStanzaListener(new PrintStanzaHandler(), ToMatchesFilter.create(getConnection().getUser())); | |
// you can find all available filters in org.jivesoftware.smack.filter package |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment