如何实现Smack 4.1.0,ConnectionConfiguration.Builder类?

时间:2015-01-21 18:42:28

标签: java xmpp smack

smack 4.1.0库有变化,有人可以告诉我如何实现ConnectionConfiguration.Builder<B extends ConnectionConfiguration.Builder<B,C>,C >类吗?

2 个答案:

答案 0 :(得分:7)

如果您通过TCP连接到服务器,则可以使用XMPPTCPConnectionConfiguration类。示例代码:

XMPPTCPConnectionConfiguration conf = XMPPConnectionConfiguration
    .builder()
    .setServiceName("example.org");
    .setHost("xmpp1.example.org")
    .setPort(Port)
    .setUsernameAndPassword("user", "password")
    .setCompressionEnabled(false)
    .build();

XMPPTCPConnection connection = new XMPPTCPConnection(conf);

来源:https://www.igniterealtime.org/builds/smack/docs/4.1.3/javadoc/org/jivesoftware/smack/ConnectionConfiguration.Builder.html

答案 1 :(得分:-1)

只需检查MyXMPP.java here的代码,其中解释了Smack 4.1的完整实现。