mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Add XMPPTCPConnection.sendSMAcknowledgement
This commit is contained in:
parent
d60b63a89a
commit
65ccec995e
2 changed files with 20 additions and 2 deletions
|
@ -1193,9 +1193,9 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
processHandledCount(ackAnswer.getHandledCount());
|
processHandledCount(ackAnswer.getHandledCount());
|
||||||
break;
|
break;
|
||||||
case AckRequest.ELEMENT:
|
case AckRequest.ELEMENT:
|
||||||
// AckRequest stanzas are trival, no need to parse them
|
ParseStreamManagement.ackRequest(parser);
|
||||||
if (smEnabledSyncPoint.wasSuccessful()) {
|
if (smEnabledSyncPoint.wasSuccessful()) {
|
||||||
packetWriter.sendStreamElement(new AckAnswer(clientHandledStanzasCount));
|
sendSmAcknowledgementInternal();
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warning("SM Ack Request received while SM is not enabled");
|
LOGGER.warning("SM Ack Request received while SM is not enabled");
|
||||||
}
|
}
|
||||||
|
@ -1499,6 +1499,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
packetWriter.sendStreamElement(AckRequest.INSTANCE);
|
packetWriter.sendStreamElement(AckRequest.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendSmAcknowledgement() throws StreamManagementNotEnabledException, NotConnectedException {
|
||||||
|
if (!isSmEnabled()) {
|
||||||
|
throw new StreamManagementException.StreamManagementNotEnabledException();
|
||||||
|
}
|
||||||
|
sendSmAcknowledgementInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendSmAcknowledgementInternal() throws NotConnectedException {
|
||||||
|
packetWriter.sendStreamElement(new AckAnswer(clientHandledStanzasCount));
|
||||||
|
}
|
||||||
|
|
||||||
public void addStanzaAcknowledgedListener(PacketListener listener) {
|
public void addStanzaAcknowledgedListener(PacketListener listener) {
|
||||||
stanzaAcknowledgedListeners.add(listener);
|
stanzaAcknowledgedListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.AckAnswer;
|
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.AckAnswer;
|
||||||
|
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.AckRequest;
|
||||||
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.Enabled;
|
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.Enabled;
|
||||||
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.Failed;
|
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.Failed;
|
||||||
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.Resumed;
|
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.Resumed;
|
||||||
|
@ -85,4 +86,10 @@ public class ParseStreamManagement {
|
||||||
return new AckAnswer(h);
|
return new AckAnswer(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AckRequest ackRequest(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
|
ParserUtils.assertAtStartTag(parser);
|
||||||
|
parser.next();
|
||||||
|
ParserUtils.assertAtEndTag(parser);
|
||||||
|
return AckRequest.INSTANCE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue