2. Quickstart

2.1. Simplest client

Here is example of simplest client sending one message.


val halcyon = Halcyon()
halcyon.configuration.let {
    it.setJID("[email protected]".toBareJID())

halcyon.request.message {
    to = "[email protected]".toJID()
        +"Art thou not Romeo, and a Montague?"


2.2. Handling changes of connection status

We can listen for changing status of connection:

halcyon.eventBus.register<HalcyonStateChangeEvent>(HalcyonStateChangeEvent.TYPE) { stateChangeEvent ->
    println("Halcyon state: ${stateChangeEvent.oldState}->${stateChangeEvent.newState}")

Available states:

  • Connecting - this state means, that method connect() was called, and connection to server is in progress.

  • Connected - connection is fully established.

  • Disconnecting - connection is closing because of error or manual disconnecting.

  • Disconnected - Halcyon is disconnected from XMPP server, but it is still active. It may start reconnecting to server automatically.

  • Stopped - Halcyon is turned off (not active).