mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 05:51:08 +01:00
Introduce StanzaBuilder
As first step to immutable Stanza types.
This commit is contained in:
parent
926c5892ad
commit
5db6191110
134 changed files with 2576 additions and 764 deletions
|
|
@ -193,8 +193,9 @@ public final class PingManager extends Manager {
|
|||
}
|
||||
};
|
||||
|
||||
Ping ping = new Ping(jid);
|
||||
connection().sendIqRequestAsync(ping, pongTimeout)
|
||||
XMPPConnection connection = connection();
|
||||
Ping ping = new Ping(connection, jid);
|
||||
connection.sendIqRequestAsync(ping, pongTimeout)
|
||||
.onSuccess(new SuccessCallback<IQ>() {
|
||||
@Override
|
||||
public void onSuccess(IQ result) {
|
||||
|
|
@ -233,7 +234,7 @@ public final class PingManager extends Manager {
|
|||
if (!connection.isAuthenticated()) {
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
Ping ping = new Ping(jid);
|
||||
Ping ping = new Ping(connection, jid);
|
||||
try {
|
||||
connection.createStanzaCollectorAndSend(ping).nextResultOrThrow(pingTimeout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2012-2015 Florian Schmaus
|
||||
* Copyright 2012-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -16,7 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ping.packet;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IqBuilder;
|
||||
import org.jivesoftware.smack.packet.SimpleIQ;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
|
@ -36,6 +38,18 @@ public class Ping extends SimpleIQ {
|
|||
setType(IQ.Type.get);
|
||||
}
|
||||
|
||||
public Ping(XMPPConnection connection, Jid to) {
|
||||
this(connection.getStanzaFactory().buildIqStanza(), to);
|
||||
}
|
||||
|
||||
public Ping(IqBuilder iqBuilder, Jid to) {
|
||||
super(iqBuilder.to(to).ofType(IQ.Type.get), ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
public Ping(IqBuilder iqBuilder) {
|
||||
super(iqBuilder, ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an XMPP Pong for this Ping.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue