mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 14:01:08 +01:00
Apply builder pattern to DiscoverInfo
This is the first transformation of an IQ type to the builder type.
This commit is contained in:
parent
36072fb25a
commit
6e32305987
30 changed files with 749 additions and 233 deletions
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.OrFilter;
|
||||
|
|
@ -120,10 +121,12 @@ public abstract class Node {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
DiscoverInfo info = new DiscoverInfo();
|
||||
info.setTo(pubSubManager.getServiceJid());
|
||||
info.setNode(getId());
|
||||
return pubSubManager.getConnection().createStanzaCollectorAndSend(info).nextResultOrThrow();
|
||||
XMPPConnection connection = pubSubManager.getConnection();
|
||||
DiscoverInfo discoverInfoRequest = DiscoverInfo.builder(connection)
|
||||
.to(pubSubManager.getServiceJid())
|
||||
.setNode(getId())
|
||||
.build();
|
||||
return connection.createStanzaCollectorAndSend(discoverInfoRequest).nextResultOrThrow();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -289,11 +289,13 @@ public final class PubSubManager extends Manager {
|
|||
Node node = nodeMap.get(id);
|
||||
|
||||
if (node == null) {
|
||||
DiscoverInfo info = new DiscoverInfo();
|
||||
info.setTo(pubSubService);
|
||||
info.setNode(id);
|
||||
XMPPConnection connection = connection();
|
||||
DiscoverInfo info = DiscoverInfo.builder(connection)
|
||||
.to(pubSubService)
|
||||
.setNode(id)
|
||||
.build();
|
||||
|
||||
DiscoverInfo infoReply = connection().createStanzaCollectorAndSend(info).nextResultOrThrow();
|
||||
DiscoverInfo infoReply = connection.createStanzaCollectorAndSend(info).nextResultOrThrow();
|
||||
|
||||
if (infoReply.hasIdentity(PubSub.ELEMENT, "leaf")) {
|
||||
node = new LeafNode(this, id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue