如何将android
服务器连接到 ConnectionConfiguration config = new ConnectionConfiguration("http://localhost:5280/admin");
XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login("Test", "Test");// Log into the server
?- S=[1,2,3,4,2,3], setof(C, R^(select(C,S,R),memberchk(C,R)), L).
S = [1, 2, 3, 4, 2, 3],
L = [2, 3].
答案 0 :(得分:0)
您可以使用Smack Android客户端。 通过使用Smack创建连接就像
一样简单 // Create the configuration for this new connection
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword("username", "password");
configBuilder.setResource("SomeResource");
configBuilder.setXmppDomain("jabber.org");
AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());
// Connect to the server
connection.connect();
// Log into the server
connection.login();
...
// Disconnect from the server
connection.disconnect();
答案 1 :(得分:0)
Smak 4.1.3 ServerName是服务器的名称。 ServerIp是服务器的ip地址,mPort是xmpp服务器的端口,通常是5222。
并确保您已注册用户,例如您的案例用户"测试"应该注册。
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setServiceName(serverName).setHost(serverIp)
.setPort(mport)
.setCompressionEnabled(false).build();
XMPPTCPConnectionconn conn= new XMPPTCPConnection(config);
conn.connect();
conn.login(username,password);