System.out.println(String.format("Initializing connection to server %1$s port %2$d", server, port));
SmackConfiguration.setPacketReplyTimeout(packetReplyTimeout);
if (service == null) {
config = new ConnectionConfiguration(server, port);
} else {
config = new ConnectionConfiguration(server, port, service);
}
if (server.equalsIgnoreCase("chat.facebook.com")) {
System.out.println("SASL Enbaled!");
SASLAuthentication.registerSASLMechanism("DIGEST-MD5", MySASLDigestMD5Mechanism.class);
config = new ConnectionConfiguration("chat.facebook.com", 5222);
config.setRosterLoadedAtLogin(true);
config.setSASLAuthenticationEnabled(true);
} else if (server.equalsIgnoreCase("gmail.com")) {
config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
config.setSASLAuthenticationEnabled(false);
}
if (port == -1) {
connection = new XMPPConnection(server);
} else {