2

I am developing a GCM Cloud Connection Server (XMPP). I am using the suggested Smack API 4.0.6 library.

How should I implement each method defined by org.jivesoftware.smack.ConnectionListener

void    authenticated(XMPPConnection connection)
void    connected(XMPPConnection connection)
void        connectionClosed()
void    connectionClosedOnError(Exception e)
void    reconnectingIn(int seconds)
void    reconnectionFailed(Exception e)
void    reconnectionSuccessful()

The only examples I can find simply log out messages.

Whats the correct way to reconnect "cleanly" when my server looses its upstream connection?

Hector
  • 2,024
  • 15
  • 69
  • 142

1 Answers1

1

Smack automatically tries to reconnect when it looses connection to your XMPP server.

Therefore, you are NOT required to implement all those methods, you can override some of them to extend their functionality.

Amedeo Baragiola
  • 314
  • 4
  • 14
  • I had seen that behaviour with reconnectingIn being called repeatedly, and never successfully reconnecting. can you rely on the Smack implementation to keep the connection open? – Hector Jan 04 '15 at 08:10
  • 1
    Well, I actually rely on it and it works well even when switching from WiFi to 3G network and vice versa. – Amedeo Baragiola Jan 04 '15 at 08:36