ConnectionConfiguration

ConnectionConfiguration

本文介绍了实例ConnectionConfiguration在4.1啪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施我的Andr​​oid应用聊天功能。所以,我已经安装了一个开放式壁炉的服务器和客户端啪图书馆,现在我已经写了code与服务器连接,但我得到它指出ConnectionConfiguration是一个抽象class.So我不能instaniate错误。你能给我说说ConnectionConfiguration的实例一些想法SMACK 4.1?

I am implementing a chat feature in my android app. So I have installed an open fire server and Smack Client library and now I have written a code to connect with the server but I am getting an error which states that ConnectionConfiguration is an abstract class.So i cant instaniate. Could you give me some idea about the instantiation of ConnectionConfiguration in SMACK 4.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();
    }

这篇关于实例ConnectionConfiguration在4.1啪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 23:22