【问题标题】:Instantiate ConnectionConfiguration in Smack 4.1在 Smack 4.1 中实例化 ConnectionConfiguration
【发布时间】:2015-05-11 07:39:46
【问题描述】:

我正在我的 Android 应用中实现聊天功能。所以我安装了一个开火服务器和 Smack 客户端库,现在我编写了一个与服务器连接的代码,但我收到一个错误,指出 ConnectionConfiguration 是一个抽象类。所以我无法实例化。您能给我一些关于 SMACK 4.1 中 ConnectionConfiguration 实例化的想法吗?

【问题讨论】:

    标签: android xmpp openfire smack


    【解决方案1】:

    尝试使用以下示例:

        XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
        config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
        config.setUsernameAndPassword(USER_ID+ "@" + DOMAIN, key);
        config.setServiceName(DOMAIN);
        config.setHost(DOMAIN);
        config.setPort(PORT);
        config.setDebuggerEnabled(true);
        config.setSocketFactory(SSLSocketFactory.getDefault());
    
        mConnection = new XMPPTCPConnection(config.build());
        try {
            mConnection.connect();
        } catch (SmackException | IOException | XMPPException e) {
            e.printStackTrace();
        }
    

    【讨论】:

    • 排除:config.setSocketFactory(SSLSocketFactory.getDefault());
    猜你喜欢
    • 2014-11-23
    • 1970-01-01
    • 2015-01-13
    • 2015-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-22
    相关资源
    最近更新 更多