启用流管理xmpp连接smack 4.1

2 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);
Run Code Online (Sandbox Code Playgroud)

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

Ana*_*ash 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();
Run Code Online (Sandbox Code Playgroud)