3
votes

In my chat application i have been using Smack 4.1 library for Xmpp communication. Now messages are sending and receiving fine, but i want to show a message to user when connection is authenticated or connected successfully. I have been using AbstractXMPPConnection object for connection. And added connection listener like,

xmppConnection.addConnectionListener(this); 

but only the callback method connectionClosed is getting called when connection is closed. And other methods like connected,authenticated etc were not calling. I have read that we have to add callConnectionAuthenticatedListener into AbstractXMPPConnection object. But don't know how to add this...Is it possible to get these call back methods in AbstractXMPPConnection.

1
Does any one have any idea..?Nidheesh

1 Answers

2
votes

I Found the solution....

The reason why the connection listeners not getting called is i have been settings the connection listener to xmpp connection object after connection established. That is my previous code was,

mXmppConnection.connect();
mXmppConnection.login();
mXmppConnection.addConnectionListener(this);

I have replaced this code with:

mXmppConnection.addConnectionListener(this);
mXmppConnection.connect();
mXmppConnection.login();

And all the callback is getting fired.... !!!