Develop your own XMPP IM cont

Source: Internet
Author: User

Article Source: http://phoenixtoday.blogbus.com/logs/17878527.html

Continue March 18 to introduce the blog based on XMPP im development, today's main summary of how to add the function of the client based on the Spark plug-in architecture, here is an example of obtaining server-side group information, the effect of the implementation of the following figure:



Spark is an IM client based on the XMPP protocol, implemented in Java. It provides APIs that can be extended using plug-in mechanisms, and the "Department" section in the diagram above is a new feature that is expanded using plug-in mechanisms. To achieve your expansion, you first need to understand the architecture of the Spark API, in which the most important thing is to understand its factory classes, which can obtain Spark such as Xmppconnection, Chatcontainer, and so on, so that you can get information about the server. With other client communications and other functions. The core of the class is Sparkmanager, this class is a series of factory class factory class (hehe, really clumsy). It's Getchatmanager () , Getsessionmanager (), Getmainwindow (), getconnection (), and other methods can be useful examples of Chat manager, Session Manager, main window, connection to the server, and so on. Basically, you can say that Sparkmanager is your interface to dealing with spark. In fact, each manager uses the singleton mode, you can not through Sparkmanager to get them, but I suggest you start from a single portal, which is conducive to the development and maintenance of the code.

Next, describe the development process of the plugin:
1. Create plug-in configuration file Plugin.xml
2, realize your own plugin class implementation (if you need to implement their own format of XML send, receive and processing, then you need to register your iqprovider here, about Iqprovider you can query smack API, simply to deal with your custom IQ Processor. )
3, packaging your plug-in (Spark has its own packaging mechanism, I studied a long time before discovering the mystery, the following introduction)
4, deployment of your plug-ins (in fact, 3, 42 steps can be blended together, of course, to use ant)

Okay, here's a practical example of the four steps above
1, Plugin.xml

<plugin>
<name>enterprise IM client</name>
<version>1.0</version>
<author>Phoenix</author>
<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.