Unable to receive message (#109)
Rajai kumar opened 4 days ago
     private lateinit var halcyon : Halcyon

    val logVersion = "1.5"

    val log = LoggerFactory.logger("halcyon.XmppClientExample")

    fun sendMessage(toAddress: String, message: String) {

        val msg = halcyon.request.message {
            to = toAddress.toJID()
            type = MessageType.Chat
            body = message
        }
        msg.send()
    }

    fun logState() {
    log.fine("XmppClientExample state is: ${halcyon.state}")

   }

fun connect(username: String, passwordVal: String) {
    halcyon = createHalcyon {
        auth {
            userJID = username.toBareJID()
            password { passwordVal }
        }

        install(MessageModule)

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

        halcyon.connect()


}

     fun registerReceiveEvent() {
         halcyon.eventBus.register(MessageReceivedEvent) {
             if (!it.stanza.body.isNullOrEmpty()) {
                 halcyon.request.message {
                     to = it.fromJID
                     body = "Echo: ${it.stanza.body}"
                 }.send()
             }
         }


    }

    fun disconnect() {
        halcyon.disconnect()
        log.fine(" XmppClientExample disconnect called-${logVersion}:${halcyon.state}")

    }

}

Above provided is the sample setup made for test. So far I have not been able to receive messages.

issue 1 of 1
Type
Help Wanted
Priority
Normal
Assignee
Version
none
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (3)
Reference
tigase/_libraries/halcyon#109
Please wait...
Page is in error, reload to recover