- Common ways to obtain ConnectionConfiguration
private void myMethod () {ConnectionConfiguration c =
String host;String serviceName;new ConnectionConfiguration(host, port, serviceName)
String host;new ConnectionConfiguration(host, port)
String serviceName;new ConnectionConfiguration(serviceName)
- Smart code suggestions by Codota
}
public void login(String userName, String password) throws XMPPException { SASLAuthentication.registerSASLMechanism("DIGEST-MD5",MySASLDigestMD5Mechanism. class); ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com",5222); config.setSASLAuthenticationEnabled(true); config.setRosterLoadedAtLogin (true); connection = new XMPPConnection(config); connection.connect(); connection.login(userName, password); }
SmackConfiguration.setPacketReplyTimeout(15000); ConnectionConfiguration connectionConfig = new ConnectionConfiguration(host, port); connectionConfig.setRosterLoadedAtLogin(true); connectionConfig.setSendPresence(true); connectionConfig.setSASLAuthenticationEnabled(false); connectionConfig.setReconnectionAllowed(true); connection = new XMPPConnection(connectionConfig);
ConnectionConfiguration config = new ConnectionConfiguration(HOST1, 5222); SmackConfiguration.DEBUG_ENABLED = true; SASLAuthentication.supportSASLMechanism("MD5", 0); System.setProperty("smack.debugEnabled", "true"); config.setCompressionEnabled(false); config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); config.setReconnectionAllowed(true); config.setSendPresence(true); config.setRosterLoadedAtLogin(true);
protected void createXmppConnection() throws XMPPException { if (logger.isDebugEnabled()) { logger.debug("Connecting to " + host + ":" + port); } ConnectionConfiguration connectionConfig = null; if (serviceName != null) { connectionConfig = new ConnectionConfiguration(host, port, serviceName); } else { connectionConfig = new ConnectionConfiguration(host, port); } // no need to load the roster (this is not an interactive app) connectionConfig.setRosterLoadedAtLogin(false); connection = new XMPPConnection(connectionConfig); }
configuration.setSecurityMode(SecurityMode.enabled); configuration.setReconnectionAllowed(true); configuration.setRosterLoadedAtLogin(false); configuration.setSendPresence(false); configuration.setSocketFactory(SSLSocketFactory.getDefault());
ConnectionConfiguration cc = new ConnectionConfiguration(domain, port, service); // SASLAuthentication.supportSASLMechanism("PLAIN", 0); cc.setSASLAuthenticationEnabled(false); cc.setRosterLoadedAtLogin(true); cc.setCompressionEnabled(false); cc.setReconnectionAllowed(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { cc.setTruststoreType("AndroidCAStore"); cc.setTruststorePassword(null); cc.setTruststorePath(null); } else { cc.setTruststoreType("BKS"); String path = System.getProperty("javax.net.ssl.trustStore"); if (path == null) { path = System.getProperty("java.home") + File.separator + "etc" + File.separator + "security" + File.separator + "cacerts.bks"; } cc.setTruststorePath(path); } XMPPConnection connection = new XMPPConnection(cc); connection.login(username, password);
config.setRosterLoadedAtLogin(true); config.setSendPresence(true); config.setSASLAuthenticationEnabled(true);
SmackConfiguration.setPacketReplyTimeout(Constants.PACKET_TIME_OUT); System.out.println(SmackConfiguration.getVersion()); config.setRosterLoadedAtLogin(false);
config.setSecurityMode(SecurityMode.enabled); config.setReconnectionAllowed(true); config.setRosterLoadedAtLogin(false); config.setSendPresence(false); config.setSocketFactory(SSLSocketFactory.getDefault());
connectionConfig.setSASLAuthenticationEnabled(true); connectionConfig.setSecurityMode(true); connectionConfig.setRosterLoadedAtLogin(true); connectionConfig.setReconnectionAllowed(true); connectionConfig.setSendPresence(false);
config.setReconnectionAllowed(true); config.setSendPresence(true); config.setRosterLoadedAtLogin(true);
config.setSASLAuthenticationEnabled(true); config.setSecurityMode(SecurityMode.required); config.setRosterLoadedAtLogin(true); config.setTruststorePath("/system/etc/security/cacerts.bks"); config.setTruststorePassword("changeit");
config.setSASLAuthenticationEnabled(true); config.setSecurityMode(SecurityMode.required); config.setRosterLoadedAtLogin(true); config.setTruststorePath("/system/etc/security/cacerts.bks"); config.setTruststorePassword("changeit");
config.setSecurityMode(SecurityMode.enabled); config.setReconnectionAllowed(true); config.setRosterLoadedAtLogin(false); config.setSendPresence(false); config.setSocketFactory(SSLSocketFactory.getDefault());
connConfig.setSASLAuthenticationEnabled(true); connConfig.setSecurityMode(SecurityMode.required); connConfig.setRosterLoadedAtLogin(true); connConfig.setSendPresence(false); connection = new XMPPConnection(connConfig);
SASLAuthentication.supportSASLMechanism("EXTERNAL"); config.setReconnectionAllowed(true); config.setRosterLoadedAtLogin(true);
private XMPPTCPConnection connect(long senderId, String apiKey) throws XMPPException, IOException, SmackException { ConnectionConfiguration config = new ConnectionConfiguration(GCM_SERVER, GCM_PORT); config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled); config.setReconnectionAllowed(true); config.setRosterLoadedAtLogin(false); config.setSendPresence(false); config.setSocketFactory(SSLSocketFactory.getDefault()); XMPPTCPConnection connection = new XMPPTCPConnection(config); connection.connect(); connection.addConnectionListener(new LoggingConnectionListener()); connection.addPacketListener(this, new PacketTypeFilter(Message.class)); connection.login(senderId + "@gcm.googleapis.com", apiKey); return connection; }
/** * 初始化XmppConnection * * @param host 服务器ip * @param port 服务器端口 */ public XMPPConnection initConnection(String host, int port) { ConnectionConfiguration configuration = new ConnectionConfiguration(host, port); // 开启debug configuration.setDebuggerEnabled(true); // // 关闭安全验证登录方式 // configuration.setSASLAuthenticationEnabled(false); // // 数据是否使用安全模式 // configuration.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); // // 设置数据是否压缩 // configuration.setCompressionEnabled(false); // // 是否给服务器发送在线状态 configuration.setSendPresence(true); // // 设置是否重新自动连接服务器 configuration.setReconnectionAllowed(true); // // asmack bug configure(ProviderManager.getInstance()); configuration.setRosterLoadedAtLogin(false); xmppConnection = new XMPPConnection(configuration); return xmppConnection; }
config.setSecurityMode(SecurityMode.enabled); config.setReconnectionAllowed(true); config.setRosterLoadedAtLogin(false); config.setSendPresence(false); config.setSocketFactory(SSLSocketFactory.getDefault());
} else { ConnectionConfiguration conf = new ConnectionConfiguration(address, port, serv_name); conf.setRosterLoadedAtLogin(true); conf.setSendPresence(false);