powered by Jive Software

Receiving IQ messages

Currently using smack-1.0-beta3 under linux, and I am trying to recieve IQ messages from a client application I am writing. I may be wrong but it seems that right now the only incoming query’'s that are supported have the namespaces:




This is fine, except I am trying to read an IQ packet using my own namespace (Just trying to learn and play around with Jabber right now). From looking in the code it seems that when an IQ packet comes in, if it isn’‘t one of the mentioned namespaces it’'s query section is ignored. Am I wrong in this or is there a way for me to get the query section of unsupported namespaces?

Ok, I played with my own solution and added some code so that I could get the query string back from IQ packets that are not currently supported. This is the code I added:

In the parseIQ function of PacketReader.java, after constructing the 3 known query types, I added this else to handle unknown namespace query sections:

else iqPacket = parseUnknownQueryNamespace(parser,namespace);

And I added this function to parse the unknown query:

private static IQ parseUnknownQueryNamespace(XmlPullParser parser, String namespace) throws Exception {
  boolean done = false;
  String queryXML=parser.getText();
  while (!done) {
    int eventType = parser.next();
    if (eventType == parser.END_TAG && parser.getName().equals("query")) {
      done = true;
  class UnknownQueryIQ extends IQ {
    private String queryXML=null;
    public UnknownQueryIQ(String queryXML) {
    public String getQueryXML() {
      return queryXML;
  return(new UnknownQueryIQ(queryXML));

Please forgive the bad formatting here

[Edited by matt on Mar 23, 2003 2:45 PM to include formatting]

I seem to be talking to myself here, but just wondering if this is an “valid” solution to handling IQ packets with uknown query namespaces or is there a better, more standard, way to do this without modifying the code?

I’‘ll likely add a way to handle generic IQ packets for a future release, but it’'s not currently supported. I think your solution is a good one for now.



Thanks, I’'ll stick with it till something more official comes out. Thanks.