Monday, February 12, 2018

Experimenting with Entity Capabilities 2.0

Enthusiastic XMPP developers probably already know about the new XEP-0390: Entity Capabilities 2.0 specification which is intended to replace the old one, XEP-0115.

I've recently implemented it and like to share my experience with it.

One of the requirements of the spec was to have both the old and new specification in place for a certain transition period.

It was pretty clear, that we need some kind of abstraction for both specs, which led to the following interface:

public interface EntityCapabilities {

    Set<Hashed> getCapabilityHashSet();

    byte[] createVerificationString(InfoNode infoNode);

    String createCapabilityHashNode(Hashed hashed);
}

Both have a set of hashes (the old one only has one, which is itself), both can create a verification string from a set of features and identities and both can create a "capability hash node", each using their own algorithm.

The interface Hashed is implemented by the old Entity Caps and also by the XEP-0300 hash element. InfoNode is a disco#info query response (features, identities, extensions).

The class structure looks like this:

Processing Entity Capabilities

When processing a presence stanza or stream features with either or both old and new Entity Capabilities, the flow has become quite complex as you can see in the following flow chart. However, the good news is that it works with only the above interface. Take a look at how it's implemented right now:

Generating Entity Capabilities

The generating entity side is a bit easier:

I hope you liked this little presentation about how both XEP-0115 and XEP-0390 can be implemented behind the same interface.

Entity Capabilties 2.0 will of course be available in the next release.

Saturday, January 27, 2018

Babbler 0.7.5 released

I am pleased to announce a new bugfx release 0.7.5 for the XMPP Java client library. It only contains non-security related bug fixes.

Here's what got fixed:

  • Add stream ID to ConsoleDebugger output (Issue #105).
  • Improve CustomIQ example and documentation (Issue #112).
  • PingManager: Make exception for feature-not-implemented (Issue #113).
  • Allow configuration of custom name server for DNS SRV resolution.
  • MUC service discovery should handle items with non-room JIDs (Issue #106).
  • Connecting to stream hosts should not exceed configured response timeout (Issue #111).
  • Fixed DataForm.getReportedFields() to work when null.
  • Fix NullPointerException in RPC Value class (Issue #117).
  • Fix memory leak on WebSocket connection failure (Issue #122)
  • Ensure WebSocket session is closed, if server does not respond with <close/> element.
  • Store avatar image using correct hash code.