Use Smack API into Spark

Hi,

I am developing a plugin for Spark, where I need to detect when a new chat session has been started between 2 users, thus I need an event which can detect this chat session, and possibly also get the session ID of it, so that I would know when the chat conversation has ended.

I have researched within the Spark API but, I found no such event which can satisfy my criteria, and then I researched within Smack API and I found some events which can possibly help me.

First of all, can I use Smack API within Spark for development? I assume so, since Spark uses Smack for certain properties, but I am not sure about it since I am trying to integrate the event that I want (from Smack API) within Spark, but it seems that it is not being recognized.

The code that I am trying is the following:

private void chatSession() {

try {

XMPPConnection connection = new XMPPConnection(“127.0.0.1”); //since I am using Openfire

connection.connect();

connection.login(“joe”, “joe”);

ChatManager chatMan = connection.getChatManager();

chatMan.addChatListener(new ChatManagerListener() {

public void chatCreated(Chat chat, boolean createdLocally) {

JOptionPane.showMessageDialog(null, "Chat Participant: " + chat.getParticipant() + " Listeners: " + chat.getListeners());

if (!createdLocally) {

JOptionPane.showMessageDialog(null, “Chat not Created locally”);

}

}

});

} catch (XMPPException ex) {

Logger.getLogger(ExamplePlugin.class.getName()).log(Level.SEVERE, null, ex);

}

}

I am not sure if I am defining the connection correctly. Anyone can offer his/her advice regarding this matter? Since it is vital for my plugin. And if there is any event within Spark which can help since from what I researched, no such event exists.

Thanks a lot and I appreciate someone who can give out some advice.

problem solved

Hi,

I am also working on the same. Could you please let me know how did you resolve it

thanks, venu