Scripts 学盟
标题:
openfire How to register Plugin as IQHandler?
[打印本页]
作者:
那个谁
时间:
2011-7-18 14:03:32
标题:
openfire How to register Plugin as IQHandler?
I am interested in write a plugin which could handle my IQ messages.
1.
I see the code to Register a plugin as an IQHandler in the link
http://www.jivesoftware.org/buil ... entation/plugin-dev
-guide.html
How to register Plugin as IQHandler?IQHandler myHandler = new MyIQHander();
IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();
iqRouter.addHandler(myHandler);[/code]
Where do you I need to add this code in the plugin? Or have to write a separate IQHandler? Can someone point me to an example for this?
作者:
那个谁
时间:
2011-7-18 14:04:26
Example:
Re: How to register Plugin as IQHandler?
public class AddressbookPlugin implements Plugin{
public AddressbookPlugin() {
IQHandler iqAddressbookHandler = new IQAddressbookHandler();
IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();
iqRouter.addHandler(iqAddressbookHandler);
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
}
public void destroyPlugin() {
}
}
protected class IQAddressbookHandler extends IQHandler {
public IQAddressbookHandler () {
super("Addressbook Handler");
}
/* (non-Javadoc)
@see org.jivesoftware.wildfire.handler.IQHandler#getInfo()
*/
public IQHandlerInfo getInfo() {
// TODO Auto-generated method stub
return new IQHandlerInfo("query","http://www.hupoo.net/protocol/addressbook");
}
/* (non-Javadoc)
@see org.jivesoftware.wildfire.handler.IQHandler#handleIQ(org.xmpp.packet.IQ)
*/
public IQ handleIQ(IQ packet) throws UnauthorizedException {
System.out.println("pa: "+packet);
return null;
}
}
复制代码
作者:
混混@普宁.中国
时间:
2011-7-21 00:22:04
这个 openfire 是不是搞聊天室的哈。。。还不知是什么玩易
作者:
那个谁
时间:
2011-7-21 08:31:01
混混@普宁.中国 发表于 2011-7-21 00:22
这个 openfire 是不是搞聊天室的哈。。。还不知是什么玩易
标准XMPP协议通信。。
欢迎光临 Scripts 学盟 (http://www.iscripts.org/)
Powered by Discuz! X2