Hello people, I recently get involved in a simple project to build a iphone xmpp based apps that interact with the openfire server.
I need the server mantains some data about users connected to it, that the client sends by IQ stanzas. I thought that the better way is to build a IQHandler as a plugin, and I try by following some tutorial found here. Unforntunately my IQHandler doesn’t handle packet with specified name and namespace.
When the client (the client use a xmpp framework for cocoa) send a the custom IQ, I read this in the server console:
C2S - SENT (27820628):
C2S - RECV (27820628): <feature
-not-implemented xmlns=“urn:ietf:params:xml:ns:xmpp-stanzas”/>
C2S - SENT (27820628):
the code i wrote is:
package it.unina.AT;
import org.jivesoftware.openfire.;
import org.xmpp.packet.IQ;
import org.jivesoftware.openfire.container.;
import org.jivesoftware.openfire.handler.IQHandler;
import org.jivesoftware.openfire.IQHandlerInfo;
import org.xmpp.packet.IQ.Type;
import org.xmpp.packet.PacketError;
import org.jivesoftware.openfire.auth.UnauthorizedException;
public class IReachYouHandler extends IQHandler
{
private IQHandlerInfo info;
public IReachYouHandler(String moduleName)
{
super(moduleName);
info = new IQHandlerInfo("query", "custom:iq:coordinate");
}
public IQHandlerInfo getInfo()
{
return info;
}
public IQ handleIQ(IQ packet) throws UnauthorizedException{
System.out.println("IReachYou handles a packet");
IQ result = IQ.createResultIQ(packet);
IQ.Type type = packet.getType();
if (type.equals(IQ.Type.get)) {
result.setChildElement("query", "custom:iq:coordinate");
result.setChildElement("coord", "custom:iq:coordinate#response");
}
else if(type.equals(IQ.Type.set))
{
result.setChildElement("query", "custom:iq:coordinate");
result.setChildElement("coord", "custom:iq:coordinate#response");
}
else
{
result.setChildElement(packet.getChildElement().createCopy());
result.setChildElement("coord", "custom:iq:coordinate#response");
result.setError(PacketError.Condition.not_acceptable);
}
return result;
}
public void initialize(XMPPServer server) {
super.initialize(server);
}
}
package it.unina.AT;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.handler.IQHandler;
import org.jivesoftware.openfire.IQRouter;
import org.jivesoftware.openfire.XMPPServer;
import it.unina.AT.IReachYouHandler;
import java.io.File;
/**
- A sample plugin for Openfire.
*/
public class IReachYouPlugin implements Plugin {
public void initializePlugin(PluginManager manager, File pluginDirectory) {
System.out.println("Starting IReachYou Plugin");
IQHandler handler = new IReachYouHandler("IReachYouHandler");
IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();
iqRouter.addHandler(handler);
}
public void destroyPlugin() {
// Your code goes here
}
}
The plugin starts normally, and i can see it by web managment.
Finally I tried to add a “loadmodule(…)” in the XMPPServer.java but I get an error at runtime, just after I start the server.
I hope someone can help me.
Thanks in advance!