Sunday, January 3, 2016

Precis (RFC 7564/7613) - A Java Implementation

Since a few months, there are a few new specifications around concerning internationalized strings in application protocols, which obsoletes the old Stringprep specification (RFC 3454).
  • RFC 7564: PRECIS Framework: Preparation, Enforcement, and Comparison of Internationalized Strings in Application Protocols
  • RFC 7613: Preparation, Enforcement, and Comparison of Internationalized Strings Representing Usernames and Passwords
  • RFC 7700: Preparation, Enforcement, and Comparison of Internationalized Strings Representing Nicknames

These are also used by XMPP, especially by the new Address Format specification, RFC 7622 (The local and resource part must conform to Precis profiles).

After working on a Java implementation for Precis for some time, I'd finally like to announce the first release of the open source software, which supports all of the three Precis specifications:

Project site with more information

Maven coordinates:


Anybody who likes to upgrade the obsolete Libidn's Stringprep class is invited to give it a try.

Sunday, September 13, 2015 Babbler Version 0.6.1 released

A new version 0.6.1 of the Java XMPP library has just been released to Maven Central.

This is primarily a bug fix release, which addresses some issues which were recently discovered and improves things here and there. It is compatible to version 0.6.0.

For detailed release notes, you can find the changelog here.

Thursday, August 13, 2015

Babbler Version 0.6.0

I am happy to announce the release of version 0.6.0 of the Java XMPP library, which has also been released to Maven Central!

This version is an important milestone because it’s the first version which is written solely for Java 8!

In particular that means, it leverages many of the new Java 8 goodies, most notably the new Date/Time API, Functional Interfaces (e.g. Predicate) and Lambda Expressions and paves the way for future improvements (e.g. Stream API) to keep the library modern.

The legacy Date API (java.util.Date/Calendar/TimeZone) has been replaced by the new java.time package, i.e. Instant, OffsetDateTime and ZoneOffset.

Event Listeners have been replaced by java.util.function.Consumer, which really saved a lot of similar interfaces and thanks to lambdas there isn’t even a syntactical difference.

New Features

A special release highlight is the support for the Jabber Component Protocol, which allows you to write External Components for an XMPP server. So the library isn’t exclusively usable for client development anymore, but now also for server component development! More about that in a future blog post.

Further new features are:

The full changelog with more information can be found here.

The updated documentation can be found here.

Support for XEP-0198: Stream Management is nearly done, but still needs some polishing, so it’s postponed to the next version.

Thanks for everybody who provided feedback and bug reports! I’m happy to hear more from you!

Wednesday, July 8, 2015

XMPP Real-time Text in Action

XMPP Real-time Text is definitively one of the most fun XMPP extension out there, from user's point of view as well as from a developer's point of view! Recently I've added support for it in the upcoming version 0.6.0 and I thought I'd make a short video which demonstrates this cool new feature in action!

It shows how it could look like when two XMPP contacts are chatting with each other and having real-time text enabled. Enjoy!

Roughly speaking you have to create a new outbound real-time message and just update its text while typing:

// Create a chat session with another user.
Chat chat = xmppClient.getManager(ChatManager.class).createChatSession(contact);
RealTimeTextManager realTimeTextManager = xmppClient.getManager(RealTimeTextManager.class);
// Create an new RTT message.
OutboundRealTimeMessage realTimeMessage = realTimeTextManager.createRealTimeMessage(chat);
TextArea textArea = new TextArea();
textArea.textProperty().addListener((observable, oldValue, newValue) -> {

When done typing, commit the message (which will send the current message as normal chat message):


On the receiver side, you can listen for it like this (and e.g. display it to a Label).

Label label = new Label();
// Upon receiving a RTT message, display it.
realTimeTextManager.addRealTimeMessageListener(e -> {
    InboundRealTimeMessage rtt = e.getRealTimeMessage();
    rtt.addRealTimeTextChangeListener(e1 -> Platform.runLater(() -> label.setText(e1.getText())));

Saturday, March 21, 2015

Version 0.5.0 Release Notes

Yay, after a few months of work, version 0.5.0 has been released and pushed to Maven Central!

This release contains some new features, most noteworthy:

And as always bug fixes, more JavaDoc, minor improvements, micro optimizations etc.

A more comprehensive list can be found in the changelog.

Special thanks goes to Markus Karg, who has provided many good ideas and test results, issued bugs and suggested improvements!

What’s next?

Moving to Java 8

0.5.0 will be the last release for Java 7, future releases will be for Java 8.

The reasons behind this decision are:
  • Java 8 offers so much cool new stuff, which is worth exploring and probably helps improving the API in a sustainable way. I am thinking especially about the Stream API, java.time and java.util.function packages and the new Async API.
  • As of now, this library is developed and tested with Java 8 only, which makes maintaining Java 7 compatibility a burden.

New Features

I only want to give a vague preview here, but my plans for new features are currently to implement XEP-0198: Stream Management and finally finish XEP-0301: In-Band Real Time Text.

Happy coding!

Friday, February 13, 2015

Bringing XMPP Chat States to JavaFX

Chat States. Everybody knows them from Instant Messengers or Facebook Chat. Those tiny notifications, which tell you, if your chat partner is currently composing a message, is (in)active or has paused typing. E.g. "XY is typing..."

XMPP defines these states in XEP-0085: Chat State Notifications as:
  • active
  • inactive
  • gone
  • composing
  • paused

Each of them - except "gone" - are applicable to a "message input interface". So let's translate them to a JavaFX TextArea!

First we define, that whenever the TextArea receives focus, we want to change the state from 'inactive' (which is the initial default state) to 'active' (if there's no text) or to 'paused' (if there's already text):

Secondly we have to change to 'composing', whenever the text changes. Easy.

The slightly tricky part is to change to the 'paused' state. To achieve this, we can set up a javafx.animation.PauseTransition and restart it everytime the text or focus has changed. Eventually, when the transition has finished (e.g. after 3 seconds), it will automatically change the state to 'paused':

Lastly, we change to 'inactive' when focus is lost:

And here's my take on a simple implementation. Enjoy!

import javafx.animation.PauseTransition;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.TextArea;
import javafx.util.Duration;
import rocks.xmpp.extensions.chatstates.model.ChatState;

public class ChatStateTextArea extends TextArea {

    private final PauseTransition pauseTransition = new PauseTransition(Duration.seconds(3));

    private final ReadOnlyObjectWrapper<ChatState> chatState = new ReadOnlyObjectWrapper<>();

    public ChatStateTextArea() {
        // This is the initial state.

        focusedProperty().addListener(new ChangeListener<Boolean>() {
            public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean
                    aBoolean2) {
                if (aBoolean2) {
                    if (getText().isEmpty()) {
                        // If we have received focus in an empty text field, immediately transition to "active".
                    } else {
                        // If we have received focus in an non-empty text field, transition to "paused".
                        // Start the timer, which will automatically transition to the next state.
                } else {

        textProperty().addListener(new ChangeListener<String>() {
            public void changed(ObservableValue<? extends String> observableValue, String s, String s2) {
                // We are in "composing" state.
                // Restart the timer.

        pauseTransition.setOnFinished(new EventHandler<ActionEvent>() {
            public void handle(ActionEvent actionEvent) {
                // When the time is up, switch to "paused", if there's any text, otherwise to active.
                if (isFocused()) {
                    if (getText() != null && !getText().isEmpty()) {
                    } else {
                } else {

    // Ommitted getters and setters for clearness.

Saturday, November 1, 2014

Version 0.4.0 now available on Maven Central

I am happy to announce version 0.4.0 of the XMPP client library "Babbler".

First of all thanks to all of you who contributed to this release (reported bugs, tested stuff, made suggestions for improvements, etc.).

There were three main requests you asked for:

  • More configuration options, especially for the connections (e.g. to set a custom SocketFactory, to set custom keep-alive intervals, etc.)
  • Modularization
  • Maven Central integration

The good news is, that this release accounts for everything of it! The bad news is that it's incomptible with the previous version, but hey, that's why it's still in development status.

More Configuration Options

The old connections only had very limited configuration options, which were passed to the constructor. Of course this didn't scale very well when the demand for more configuration options increases. Therefore there's now a configuration object, which let's you configure the connection.

Instead of passing a connection to the XmppSession, you now pass the configuration object to it. This allows you to reuse a configuration for multiple sessions. The session then creates a new connection based on the configuration.

Here's how it looks like.

There's also a configuration object for the whole XmppSession, e.g. to set a debugger. It also takes responsibility to create the JAXBContext, which was previously done in the XmppSession. This has the advantage that it doesn't need to be recreated for each new session (because it is quite expensive to create it).


The previous version did a bad job on modularization, in fact you weren't able to only use XMPP core functionality without having to include all extensions. This version now improves on this situation. There's a better separation between core and extensions, so that you only need to include a small jar file, if you only want XMPP core functionality.

Maven Central Integration

Some people asked for it and it has always been a long-term goal: Maven Central integration. Well, it now happened earlier than I thought, this is the first version to be available on Maven Central!

They made me register a domain, so that they could assign a unique groupId:

The new domain also made me feel like changing the package name, in order to fit the groupId and generally it's the convention to use the domain you control for the package name. Given that the API wouldn't be compatible anyway (due to the mentioned new configuration objects and also due to the modularization) I changed the package name to "rocks.xmpp" and also took the opportunity to refactor some other package names. So, if you are migrating from a previous version, you have to refresh your import statements.

Here are the coordinates:


Visual Debugger

One cool new feature is the visual XMPP viever/debugger (written in JavaFX). I've already blogged about it in my last post, but here's a small glimpse, how it looks like:

There have also been other new features, improvements and bug fixes, which are listed in the changelog.

As always: I am happy about feedback!