Overview

Smack is a library for client-to-server XMPP connections to perform real-time communications and data exchange. This includes, but is not limited to, instant messaging and group chat. More generically speaking, it allows you to easily exchange data in various ways: For example fire-and-forget, publish-subscribe, between human and non-human endpoints. The use cases include M2M, IoT, and many more.

Smack is a pure Java library, open-source and highly modular. It runs on Android and Java SE. The API strives to be easy to use but yet powerful.

Key Advantages

Smack is extremely simple to use, yet provides a powerful API. Sending a text message to a user can be accomplished in only a few lines of code.
{@code
AbstractXMPPConnection connection = new XMPPTCPConnection("mtucker", "password", "jabber.org");
connection.connect().login();

Message message = connection.getStanzaFactory()
   .buildMessageStanza()
   .to("jsmith@igniterealtime.org")
   .setBody("Howdy! How are you?")
   .build();

connection.sendStanza(message);

connection.disconnect();
}

Smack doesn't force you to code at the protcol level of XMPP. The library provides intelligent higher level constructs, often called {@link org.jivesoftware.smack.Manager}, which let you program more efficiently. Other examples of those constructs are the Chat and Roster classes.

Smack comes with APIs for easy machine-to-machine communication. You can set any number of properties on each message, including properties that are Java objects.

License

Smack is open-source and most parts are under the Apache License 2.0, which means you can incorporate Smack into your commercial or non-commercial applications. Some parts of Smack may be under a different open-source license. Please refer to the individual subprojects for their license statement.

Note that the Apache License 2.0 requires that the contents of a NOICE text file are shown "…within a display generated by the Derivative Works, if and wherever such third-party notices normally appear.". Smack comes with such a NOTICE file. The content of Smack's NOTICE file can conveniently be retrieved using {@link org.jivesoftware.smack.Smack#getNoticeStream}.

About XMPP

XMPP (eXtensible Messaging and Presence Protocol) is an open protocol standardized by the Internet Engineering Task Force (IETF) and supported and extended by the XMPP Standards Foundation (XSF).

Smack Modules

Smack is meant to be easily embedded into any existing Java application. The library ships as several modules to provide more flexibility over which features applications require.

Main API Entry Points

Smack Extensions

Since the X in XMPP stands for eXstensible, Smack comes with many built-in extensions for XMPP. Click

{@link org.jivesoftware.smackx}

for an overview of all supporteted XMPP extensions of Smack.

Some selected extensions are

Configuration

Smack has an initialization process that involves 2 phases.

Initialization is accomplished via a configuration file. By default, Smack will load the one embedded in the Smack jar at _org.jivesoftware.smack/smack- config.xml_. This particular configuration contains a list of initializer classes to load. All manager type classes that need to be initialized are contained in this list of initializers.