Development of XMPP client library Smack 4.0.6

Source: Internet
Author: User

Development of XMPP client library Smack 4.0.6

Development of XMPP client library Smack 4.0.6

Author: chszs, reprinted with note. Blog homepage: http://blog.csdn.net/chszs

Iii. Features of the Smack Library
1. extremely easy to use and powerful API functions
Only a few lines of code are required to send a text message to a user:

AbstractXMPPConnection connection = new XMPPTCPConnection("mtucker", "password", "jabber.org");connection.connect();connection.login();Chat chat = ChatManager.getInstanceFor(connection).createChat("jsmith@jivesoftware.com", new MessageListener(){public void processMessage(Chat chat, Message message){System.out.println("Received message: " + message);}});chat.sendMessage("Howdy!");

2. The complexity of underlying data packet assembly is isolated, and corresponding libraries are provided to complete these functions. Smack provides more intelligent high-level structures, such as Chat and Roster classes, so that development is more efficient.
1) You do not need to be familiar with the XML format of XMPP, or even understand XML.
2) provides simple M2M communication
Smack allows developers to set a large number of attributes for each message. attributes can also contain Java objects.
3) open source code based on the Apache license, which means you can put Smack into your own commercial software.

Iv. Composition of the Smack Library
The Smack library can be embedded in any Java application. The Smack library consists of several JAR files, which are flexible.
1. smack-core.jar
Provides core XMPP functions. All are the XMPP features defined in the xmpp rfc specification.
2. smack-extensions.jar
Supports many extension (XEP) features defined by the XMPP Standards Foundation. This includes group chat, file transmission, and user search.
You can view the extension manual in the future:
Https://github.com/igniterealtime/Smack/blob/master/documentation/extensions/index.html
(Currently, it is still invalid)
3. smack-experimental.jar
Supports many experience (XEP) features defined by the XMPP Standards Foundation. Its APIs and features are considered unstable.
4. smack-legacy.jar
Supports many legacy (XEP) features defined by the XMPP Standards Foundation.
5. smack-bosh.jar
Support BOSH communication (defined by XEP-0124 specifications ). This code is considered in Beta stage.
6. smack-jingle.jar
Jingle is supported. This code is very old and is currently in the state of no maintenance.
7. smack-resolver-dnsjava.jar
Dns srv records can be parsed, mainly for platforms that do not support javax. naming APIs.
8. smack-debug.jar
Enhanced GUI Debugger for protocol traffic. When the debug mode is enabled, it is automatically used if it is in the class path.
You can view the "debugging mode" document later:
Https://github.com/igniterealtime/Smack/blob/master/documentation/debugging.html
(Currently, it is still invalid)

5. Smack Configuration
The initialization process of Smack involves two-stage calls.
1. initialize system Properties
Initialize all system accessible properties through the SmackConfiguration class. These properties retrieve the property values through the getXXX method.
2. initialize the startup class
If any class inherits the SmackInitializer interface, it can be initialized after the initialize () method is called. This means that the class to be initialized is active after startup.
If you do not inherit the SmackInitializer interface, you must place a static code block for initialization-it will be automatically executed during class loading.

The initialization is completed through the configuration file. By default, Smack loads the embedded configuration file in the Smack JAR file (which is located at org. jivesoftware. smack/smack-config.xml ). The specified configuration file contains a list of classes to be loaded and initialized. All manager classes need to be initialized. These manager classes are included in the initialization list mentioned above.


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.