Instantiate ConnectionConfiguration in Smack 4.1

▼魔方 西西 提交于 2019-12-07 19:06:18

问题


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?


回答1:


Try to use the example below:

    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();
    }


来源:https://stackoverflow.com/questions/28954035/instantiate-connectionconfiguration-in-smack-4-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!