Skip to content

Instantly share code, notes, and snippets.

@fpopic
Created June 1, 2015 22:14
Show Gist options
  • Select an option

  • Save fpopic/291fc9f69d33a1940810 to your computer and use it in GitHub Desktop.

Select an option

Save fpopic/291fc9f69d33a1940810 to your computer and use it in GitHub Desktop.
public void connect() throws IOException, XMPPException, SmackException {
xmpptcpConnection = new XMPPTCPConnection(XMPPTCPConnectionConfiguration.builder()
.setSecurityMode(disabled)
.setResource(resource)
.setHost(localhost)
.setServiceName(serviceName)
.setPort(port)
.setSendPresence(true)
.setDebuggerEnabled(true)
.build()
);
// Unutar n miliseknudi provjeri je li dosla poruka o primitku
xmpptcpConnection.setPacketReplyTimeout(10000);
// Prepare listeners before inital connecting.
xmpptcpConnection.addConnectionListener(this);
// Povezi se
xmpptcpConnection.connect();
// Provjerava dostupnost Openfire servera svakih 10*60s = 10min.
PingManager.setDefaultPingInterval(600);
PingManager.getInstanceFor(xmpptcpConnection).registerPingFailedListener(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment