1
0
Fork 0
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:
Florian Schmaus 2014-10-28 12:22:05 +01:00
parent d60b63a89a
commit 65ccec995e
2 changed files with 20 additions and 2 deletions

View file

@ -1193,9 +1193,9 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
processHandledCount(ackAnswer.getHandledCount());
break;
case AckRequest.ELEMENT:
// AckRequest stanzas are trival, no need to parse them
ParseStreamManagement.ackRequest(parser);
if (smEnabledSyncPoint.wasSuccessful()) {
packetWriter.sendStreamElement(new AckAnswer(clientHandledStanzasCount));
sendSmAcknowledgementInternal();
} else {
LOGGER.warning("SM Ack Request received while SM is not enabled");
}
@ -1499,6 +1499,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
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) {
stanzaAcknowledgedListeners.add(listener);
}

View file

@ -20,6 +20,7 @@ import java.io.IOException;
import org.jivesoftware.smack.packet.XMPPError;
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.Failed;
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.Resumed;
@ -85,4 +86,10 @@ public class ParseStreamManagement {
return new AckAnswer(h);
}
public static AckRequest ackRequest(XmlPullParser parser) throws XmlPullParserException, IOException {
ParserUtils.assertAtStartTag(parser);
parser.next();
ParserUtils.assertAtEndTag(parser);
return AckRequest.INSTANCE;
}
}