jaxmpp icon indicating copy to clipboard operation
jaxmpp copied to clipboard

Java XMPP client library

Tigase Java XMPP Client Library

What it is

Tigase Java XMPP Client Library is an XMPP client library written in a Java programming language. It provides implementation of core of the XMPP standard and processing XML. Additionally it provides support for many popular extensions (XEP's).

This repository contains source files of the library.

Features

JaXMPP implements support for RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core and RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence. Additionally it supports many popular XEPs. Below is a list of some of the supported XEPs:

Compilation

Maven is required tool to compile library:

mvn package

To build Android JaXMPP module just use android profile:

mvn package -Pandroid 

Note, that following requirements has to be met:

  • Java 1.8 has to be used
  • Android sdk must be installed (e.g.: brew install android-sdk)
  • Proper tooling mus be installed (e.g.: sdkmanager "platform-tools" "platforms;android-28")
  • ANDROID_HOME must be declared. (e.g.: export ANDROID_HOME=/usr/local/Caskroom/android-sdk/4333796)

Releasing

  • prepare release: mvn -Pdist clean release:clean release:prepare
  • perform: mvn -Pdist release:perform

Simple client

Following snippet (in groovy) creates simple XMPP client, that connects to the server and prints out all incomming messages (waits for 1 minut and disconnects)

import tigase.jaxmpp.core.client.BareJID
import tigase.jaxmpp.core.client.JID
import tigase.jaxmpp.core.client.SessionObject
import tigase.jaxmpp.core.client.exceptions.JaxmppException
import tigase.jaxmpp.core.client.xmpp.modules.chat.Chat
import tigase.jaxmpp.core.client.xmpp.modules.chat.MessageModule
import tigase.jaxmpp.core.client.xmpp.stanzas.Message
import tigase.jaxmpp.j2se.Jaxmpp

final Jaxmpp contact = new Jaxmpp()

tigase.jaxmpp.j2se.Presence.initialize(contact);

contact.getModulesManager().register(new MessageModule());

contact.getProperties().setUserProperty(SessionObject.USER_BARE_JID, BareJID.bareJIDInstance("admin@atlantiscity"))
contact.getProperties().setUserProperty(SessionObject.PASSWORD, "admin")

contact.getEventBus().addHandler(MessageModule.MessageReceivedHandler.MessageReceivedEvent.class,
        new MessageModule.MessageReceivedHandler() {

            @Override
            public void onMessageReceived(SessionObject sessionObject, Chat chat, Message stanza) {
                System.out.println("received message: " + stanza.getBody());
            }
        });

println("Loging in...");

contact.login(true)

if (contact.isConnected()) {
    TimeUnit.MINUTES.sleep(1);
    contact.disconnect()
}

Support

When looking for support, please first search for answers to your question in the available online channels:

If you didn't find an answer in the resources above, feel free to submit your question as new issue on GitHub or, if you have valid support subscription, open new support ticket.

License

Tigase Tigase Logo Official Tigase repository is available at: https://github.com/tigase/jaxmpp/.

Copyright (c) 2004 Tigase, Inc.

Licensed under AGPL License Version 3. Other licensing options available upon request.