powered by Jive Software

Newbie Question: IQ questions

First off, thanks for writing Smack!

I am having some problems figuring out how iq packets are constructed using

Smack. In the IQ class javadoc, it reads "The actual data of an IQ packet

is normally enclosed in the query section with a specific namespace". How

is the specific namespace set?

In short, can you send me a few lines of code that would demonstrate how the

following IQ packets are sent? The key issues for me is the fact that the

namespaces are different and one packet has internal data.



<iq type=“get”



<iq type=’‘set’’>

<query xmlns=’‘jabber:iq:roster’’>





For the first beta of Smack, IQ support is pretty limited. Basically, Authentication is the only fully-realized IQ packet class.

The plan is to support registration and all roster operations via higher-level classes (with the idea that you generally shouldn’‘t need to code at the packet level). So, there will be a AccountManager and a Roster class. We’'ll probably also add a GenericIQ class to facilitate creating arbitrary IQ packets.

For now, you could create your own IQ packets with code like the following:

// Create an anonymous inner-class. You could also
// create a full-fledged class instead.
IQ registerIQ = new IQ () {
    public String getQueryXML() {
        return "<query xmlns=''jabber:iq:roster''>" +
               "<item jid=''contact@host'' name=''contact''/> " +
    }  };

Obviously, this isn’'t ideal, but a cleaner solution will have to wait for an upcoming beta.



IQ registerIQ = new IQ () {

public String getQueryXML() {

return “<query xmlns=’‘jabber:iq:register’’>” +

“” + user + " " +

“” + password + " " +






Sorry for second post, ive missed

its example for user registration. id try it with smack beta2 and JabberD with default settings and this really works