设为首页收藏本站

Scripts 学盟

 找回密码
 加入学盟

QQ登录

只需一步,快速开始

查看: 1828|回复: 3
打印 上一主题 下一主题

openfire How to register Plugin as IQHandler? [复制链接]

Rank: 8Rank: 8

跳转到指定楼层
1#
那个谁 发表于 2011-7-18 14:03:32 |只看该作者 |倒序浏览
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?

2

查看全部评分

分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0

Rank: 8Rank: 8

2#
那个谁 发表于 2011-7-18 14:04:26 |只看该作者
  1. Example:


  2. Re: How to register Plugin as IQHandler?


  3. public class AddressbookPlugin implements Plugin{


  4.       
  5.      public AddressbookPlugin() {

  6.           IQHandler iqAddressbookHandler = new IQAddressbookHandler();

  7.           IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();

  8.           iqRouter.addHandler(iqAddressbookHandler);

  9.      }


  10.      public void initializePlugin(PluginManager manager, File pluginDirectory) {     

  11.      }


  12.      public void destroyPlugin() {         

  13.      }


  14. }


  15. protected class IQAddressbookHandler extends IQHandler {

  16.           public IQAddressbookHandler () {

  17.                super("Addressbook Handler");

  18.           }

  19.           /* (non-Javadoc)

  20.             
  21. @see org.jivesoftware.wildfire.handler.IQHandler#getInfo()

  22.            */

  23.           public IQHandlerInfo getInfo() {

  24.                // TODO Auto-generated method stub

  25.                return new IQHandlerInfo("query","http://www.hupoo.net/protocol/addressbook");

  26.           }

  27.           /* (non-Javadoc)

  28.             
  29. @see org.jivesoftware.wildfire.handler.IQHandler#handleIQ(org.xmpp.packet.IQ)

  30.            */

  31.           public IQ handleIQ(IQ packet) throws UnauthorizedException {

  32.                System.out.println("pa: "+packet);

  33.                return null;

  34.           }

  35.            
  36.     }
复制代码

使用道具 举报

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

3#
混混@普宁.中国 实名认证  发表于 2011-7-21 00:22:04 |只看该作者
这个 openfire 是不是搞聊天室的哈。。。还不知是什么玩易

使用道具 举报

Rank: 8Rank: 8

4#
那个谁 发表于 2011-7-21 08:31:01 |只看该作者
混混@普宁.中国 发表于 2011-7-21 00:22
这个 openfire 是不是搞聊天室的哈。。。还不知是什么玩易

标准XMPP协议通信。。

使用道具 举报

您需要登录后才可以回帖 登录 | 加入学盟

手机版|Scripts 学盟   |

GMT+8, 2024-5-9 21:10 , Processed in 1.064409 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部