powered by Jive Software

Changes to API dealing with direct Chat

I haven’t had to do any development with the Smack API for a few years (been running in production trouble free for quite a few years); however, I have to integrate with a new product now and they have a chat requirement. So we are standing up new instances of OpenFire using newest Smack 3.1.0 (previous development was using Wildfire with Smack 2.x).

I have noticed that initiating a direct Chat session has changed slightly in the newest version and I just need some clarificaiton. It now uses a ChatManager to create the chat and the createChat method now takes a MessageListener as a parameter. How does this MessageListener differ from the PacketListener I used in previous versions? Also, it appears I still need to use PacketListener to receive the first direct packet but then responses use the MessageListener? Can I just send null in for MessageListener to createChat() and then depend on the PacketListener?

To illustrate, here is my previous handlePacket() method (working great in production for quite a few years):

public void processPacket(Packet packet) {
        if (packet instanceof Message) {
            Message message = (Message) packet;
            if (message.getType().equals(Message.Type.groupchat)) {
                if (chatSound != null) {
                }                 this.broadcastChatListener.handleBroadcastChatMessage(message);
            }             if (message.getType().equals(Message.Type.chat)) {
                this.lastSender = message.getFrom();

It appears that no matter what I have to use this to get the first direct chat message. However, after that can I still use this to get responses? What is the point of MessageListener?