ConnectionConfiguration config = new ConnectionConfiguration("wang-think");
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
connection = new XMPPConnection(config);
// Connect to the server
connection.connect();
// Log into the server
connection.login("majian", "majian", "SomeResource");
// Disconnect from the server
//connection.disconnect();//需要时可以使用该方法断开连接
while(true);////死循环,维持该连接不中断Smack开发Demo一------管理连接
最新推荐文章于 2024-12-08 15:27:05 发布
本文介绍如何使用Java进行XMPP服务器的连接配置、启用压缩及SASL认证,并展示具体的连接与登录代码示例。

1万+

被折叠的 条评论
为什么被折叠?



