Component vs IQHandler

When creating a component you are saying that the server will provide a new service and packets should be routed to the component to execute the new service. Therefore, each component will provide a new subdomain (eg. search.myserver.com) for the server (eg. myserver.com). So packets whose domain matches the subdomain that your component is  handling will be routed to your component. This includes Presence, Message and IQ packets. Moreover, when you build a component you may be able to run your component as an external component. That means that it will be a different process in the OS and that the component will connect to the server using sockets.

 

On the other hand, IQHandler is an internal class of Jive Messenger where each subclass will handle a certain type of IQ packet. So IQ packets sent to the server whose domain matches the server domain or IQ packets with no TO attribute will be handled by the server. The server will delegate the responsibility to an IQHandler subclass. The subclass to use will depend on the namespace of the child element in the IQ packet.

 

To send packets from your plugin you have two options. The first option could be used if your plugin will always run on the same JVM of JM.

 

XMPPServer.getInstance().getPacketRouter().route(<Packet>); 

 

but, if your plugin contains a component that may be used as an external component then you should use the ComponentManager for sending packets:

 

componentManager.sendPacket(this, <Packet>); 

 

 

External components are transparent to people that want to use a service in an XMPP server. Lets say that a server's domain is example.com and you connect the weather example, included in Whack, to the server. The weather external component will use the address weather.example.com . That means that any packet sent to weather.example.com will be redirected by the server to the external component. The external component will process the packet and send back a reply to the user.External components use a different port than clients or servers. Make sure to connect to the external components port as shown in the admin console.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值