Smack 4.1.x upgrade Guide

Source: Internet
Author: User

Smack 4.1.x upgrade Guide
I. Major improvements to Smack 4.1

Smack 4.1.x has two major improvements:
1) Support XEP-198 specifications, that is, stream management
2) native support for Android
Smack 4.1 allows the original aSmack database to be dumped into the garbage. Note that the latest version of aSmack is only 4.0.7.

Ii. Stream Management

Stream Management)
Smack 4.1 is disabled by default for stream management. You can enable Stream Management in the following ways:
XMPPTCPConnection. setUseStreamManagement (true)

Flow Management specifications available: http://xmpp.org/extensions/xep-0198.html
Stream Management is an extension of XMPP. It adds Acknowledgement and stream recovery. This means that if you use Jabber on your mobile phone, messages will not be lost even if they are not in the service area.
Jaber uses the TCP protocol, which is a reliable protocol. When a user loses a connection, the message may be lost. At this time, the service area still maintains a TCP connection to the client to send messages, when the client leaves the service area, the message may be lost.
In good cases, when the client leaves the service area, the Network Provider immediately closes the connection. In this way, the message will be saved as an offline message to the server. In some bad cases, when the client leaves the l service area, and the server connection is not broken, the server forwards the message to the client, and the message will be lost.
The XEP-198 specification is a solution to this situation. It does not allow clients to stay connected offline, but introduces two important elements, the client can retrieve the message after it misses the message.
The validation section allows the server and client to confirm each request sent for a single message or group message. Once a confirmation is received, the message is considered successfully delivered.
Stream recovery is used when the connection is rebuilt. By including the serial number in the validation section, both the client and server can know when the message was interrupted and send the message again.
These two mechanisms can provide reliable guarantee for each delivered message, and the same mechanism can also be used for S2S (server connection server ).

Iii. Smack 4.1 API changes

Major API changes for Smack 4.1.x include:

  1. Change XMPPConnection to interface
    When declaring a connection, you can use the class of AbstractXMPPConnection or XMPPConnection as the static type.

  2. SASL authentication is implemented again
    For the custom SASL mechanism, you may need to adjust the code.

  3. Added the IQ request handle API
    Packet listeners and Packet collectors can no longer listen to IQ requests, that is, IQ's "get" and "set" types.

  4. XMPPConnection. addPacketListener method discarded
    Instead, use the addAsyncPacketListener method to add the asynchronous packet listener or the addSyncPacketListener method to replace it.

  5. StringUtils tool class
    The StringUtils tool class is added to the XmppStringUtils package (in the jxmpp-core Package). The method name also changes, for example, parseName is changed to parseLocalpart.

  6. Changes in the message listener class
    The MessageListener class of the message listener is changed to ChatMessageListener. The MessageListener class name cannot be used.

  7. The connection configuration class uses the Builder mode.
    The connection configuration ConnectionConfiguration class uses the Builder design mode.

  8. FormField. getType and Form. getType
    Both FormField. getType and Form. getType are changed to Enum of Enumeration type.

  9. Packet interface discarded
    The Packet interface is discarded. Use the getStanzaId method of the new Stanza class to replace the getPacketID method.

  10. Roster Class Changes
    Use Roster. instance to obtain an instance, which was originally obtained by the XMPPConnection. getRoster method.

  11. ConnectionListener. authenticated method changes
    The ConnectionListener. authenticated method adds a Boolean parameter resumed.

  12. The XMPPTCPConnection. addStanzaAcknowledgedListener method cancels an exception.
    The XMPPTCPConnection. addStanzaAcknowledgedListener method cancels the StreamManagementNotEnabledException exception.

  13. If SASL extension is used, use ConnectionConfiguration. Builder. allowEmptyOrNullUsernames

  14. SmackConfiguration. DEBUG_ENABLED changed to SmackConfiguration. DEBUG

This article permanently updates the link address:

Related Article

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.