启用流管理xmpp连接smack 4.1

时间:2015-07-10 01:25:44

标签: xmpp smack stream-management

我尝试通过这段代码启用流管理(XEP-0198)

XMPPTCPConnectionConfiguration connConfig = XMPPTCPConnectionConfiguration.builder().setHost(HOST)
            .setPort(PORT).setDebuggerEnabled(true).setSecurityMode(SecurityMode.disabled)
            .setUsernameAndPassword(USERNAME, PASSWORD).setServiceName(SERVICE).build();

    XMPPTCPConnectionconnection = new XMPPTCPConnection(connConfig);

        connection.setPacketReplyTimeout(TIME_OUT);
        connection.connect();
        connection.login();
        connection.setUseStreamManagement(true);

但后来当我检查流管理时,它返回false。

1 个答案:

答案 0 :(得分:5)

我猜你需要在连接到xmpp之前设置流管理。

XMPPTCPConnectionConfiguration connConfig = XMPPTCPConnectionConfiguration.builder().setHost(HOST)
        .setPort(PORT).setDebuggerEnabled(true).setSecurityMode(SecurityMode.disabled)
        .setUsernameAndPassword(USERNAME, PASSWORD).setServiceName(SERVICE).build();

XMPPTCPConnectionconnection = new XMPPTCPConnection(connConfig);

    connection.setUseStreamManagement(true);
    connection.setPacketReplyTimeout(TIME_OUT);
    connection.connect();
    connection.login();