XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder()
.setXmppDomain("404.city").setUsernameAndPassword("user", "password")
.setCompressionEnabled(false)
.setSecurityMode(ConnectionConfiguration.SecurityMode.required)
.setCustomSSLContext(sslcont)
.build();
XMPPTCPConnection connection = new XMPPTCPConnection(conf);
if(connection.isConnected()){
System.out.println("already connected");
return;
}
connection.connect();
connection.login();
我是新手,我试图用smack 4.2.1连接xmppserver(openfire)。代码是用用户名和密码登录的,但是当我尝试修改代码时。没有loginAnonymous函数
我如何以匿名身份登录?请指导我
答案 0 :(得分:1)
有两个函数allowEmptyOrNullUsernames()和performSasAnonymousAuthentication()。当设置XMPPTCPConnection的配置时,可以调用它。