How to send custom XML packets using Java’s smack API?
•
Java
I use the smack API in Java to connect to my XMPP server
I want to send a customized message package as follows:
<message to="you@MyServer.com" type="chat" MYFIELD="custom stuff"> <body> hi </body> <CUSTOM_STANZA A="..." B="..."> C="..." D="..." </CUSTOM_STANZA> </message>
I guess I created my own packet, which returns the toxml () method of this XML But it doesn't seem to work
Any help would be appreciated
Solution
You need to define a custom class that should implement extensionelement (as shown in @ flow)
A very detailed explanation that produces the following sections can be used in this answer
<message id='923442621149' type='chat'><body>shanraisshan</body> <reply xmlns='shayan:reply' rText='this is custom attribute'/> </message>
Where reply is a custom extension that contains
Element (reply) > namespace (Shayan: reply)
The default XMPP namespace list is available on the official XMPP website
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码