Creating my own XMPP extension - HOWTO?

Hi … i defined a protocoll of messages that sould be exchanged between a xmpp server and a client (eg openfire and a spark plugin)

now i figured out that iq packets are the correct type of messages - but what do i have to do to get java objects from my connection …

i know how to build a message interceptor and i know how to send subclasses of Packet. but

  • how to create the correct subclasses of IQ? - what do i have to consider?

  • how to configure my packetinterceptor that i can retrieve the above sent objects from the connection?

the manuals are not that detailed to help me - so if anyone can tell me more (i think the best would be a small example) that would be very nice

I figured out some tings … and by now i’'m able to construct a iq packet (at least i think that i construct one) but the reciever i wrote doesnt get any messages.

i add the output of the smack-debugger:

The 3 source Files i have are:

package reciever;

import org.jivesoftware.smack.PacketListener;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.filter.PacketFilter;

import org.jivesoftware.smack.packet.Packet;

public class Reciever {

/**

  • @param args

*/

public static void main(String[] args) {

try {

XMPPConnection.DEBUG_ENABLED = true;

XMPPConnection connection = new XMPPConnection(“jgrimm19”);

connection.connect();

connection.addPacketListener(new PacketListener() {

public void processPacket(Packet p) {

System.out.println§;

}}, new PacketFilter() {

public boolean accept(Packet p) {

return true;

}});

connection.login(“reciever”, “RECIEVER”);

} catch (Exception e) {

e.printStackTrace();

}

}

}

package sender;

import org.jivesoftware.smack.XMPPConnection;

import common.ExtensionPackage;

public class Sender {

/**

  • @param args

*/

public static void main(String[] args) {

try {

XMPPConnection.DEBUG_ENABLED = true;

XMPPConnection connection = new XMPPConnection(“jgrimm19”);

connection.connect();

connection.login(“sender”, “SENDER”);

ExtensionPackage p = new ExtensionPackage(“Hallo Welt!”);

p.setTo(“reciever@jgrimm19”);

p.setFrom(“sender@jgrimm19”);

connection.sendPacket§;

} catch (Exception e) {

e.printStackTrace();

}

}

}

package common;

import org.jivesoftware.smack.packet.IQ;

public class ExtensionPackage extends IQ {

private String testdata = null;

public ExtensionPackage() {

// enpty constructor for introspection parser

}

public ExtensionPackage(String testdata) {

this.testdata = testdata;

}

public String getTestdata() {

return this.testdata;

}

public void setTestdata(String testdata) {

this.testdata = testdata;

}

public String getChildElementXML() {

StringBuilder buf = new StringBuilder();

buf.append("");

return buf.toString();

}

}

there’'s also a eclipse project that contains my project: http://smilingj.net/xmpp_questions/extensions/xmpp_extension_test.zip

i hope someone can help me because i’'ll need it to write my exam - and i realy like to do that with smack/spark/openfire

i found some solutions (i think) - and some examples are here:

http://smilingj.net/open_download/XMPPExtensionExample_smack.zip

http://smilingj.net/open_download/XMPPExtensionExample_openfire.zip

these classes are based on this article

found some external documentation/examples