Smack has support for XEP-172: Simply use
Nick nick = (nick) msg.getExtension("nick");
and then
nick.getName();
to retrieve the nickname. javadoc
문제
I have the following message being received on my client from a PSI client:
<message from="testing@example.com/PAT" type="chat" xmlns="jabber:client" id="ab1ca" to="testing2@example.com/Smack">
<active xmlns="http://jabber.org/protocol/chatstates"/>
<nick xmlns="http://jabber.org/protocol/nick">testing</nick>
How is it that I can parse the nick extension to get the "testing" value?
DefaultPacketExtension ext2 = (DefaultPacketExtension) msg.getExtension("nick");
Only provides me with the option to get a value using getValue(String) if it's the following format:
<foo xmlns="http://bar.com">
<color>blue</color>
<food>pizza</food>
</foo>
The embedded packet extension doesn't allow me either, allowing me to only retrieve further packet extensions.
So how is it that I can get the "testing" value if it is not in an XML format?
해결책
Smack has support for XEP-172: Simply use
Nick nick = (nick) msg.getExtension("nick");
and then
nick.getName();
to retrieve the nickname. javadoc