code clean up for resumed processing

This commit is contained in:
Daniel Gultsch 2022-08-29 19:30:03 +02:00
parent f6ab3dd068
commit 7ea4f64ce4

View file

@ -694,17 +694,26 @@ public class XmppConnection implements Runnable {
} }
} }
private void processResumed(final Element resumed) { private void processResumed(final Element resumed) throws StateChangingException {
this.inSmacksSession = true; this.inSmacksSession = true;
this.isBound = true; this.isBound = true;
this.tagWriter.writeStanzaAsync(new RequestPacket(smVersion)); this.tagWriter.writeStanzaAsync(new RequestPacket(smVersion));
lastPacketReceived = SystemClock.elapsedRealtime(); lastPacketReceived = SystemClock.elapsedRealtime();
final String h = resumed.getAttribute("h"); final String h = resumed.getAttribute("h");
if (h == null) {
resetStreamId();
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
}
final int serverCount;
try { try {
ArrayList<AbstractAcknowledgeableStanza> failedStanzas = new ArrayList<>(); serverCount = Integer.parseInt(h);
} catch (final NumberFormatException e) {
resetStreamId();
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
}
final ArrayList<AbstractAcknowledgeableStanza> failedStanzas = new ArrayList<>();
final boolean acknowledgedMessages; final boolean acknowledgedMessages;
synchronized (this.mStanzaQueue) { synchronized (this.mStanzaQueue) {
final int serverCount = Integer.parseInt(h);
if (serverCount < stanzasSent) { if (serverCount < stanzasSent) {
Log.d( Log.d(
Config.LOGTAG, Config.LOGTAG,
@ -724,11 +733,8 @@ public class XmppConnection implements Runnable {
} }
Log.d( Log.d(
Config.LOGTAG, Config.LOGTAG,
account.getJid().asBareJid() account.getJid().asBareJid() + ": resending " + failedStanzas.size() + " stanzas");
+ ": resending " for (final AbstractAcknowledgeableStanza packet : failedStanzas) {
+ failedStanzas.size()
+ " stanzas");
for (AbstractAcknowledgeableStanza packet : failedStanzas) {
if (packet instanceof MessagePacket) { if (packet instanceof MessagePacket) {
MessagePacket message = (MessagePacket) packet; MessagePacket message = (MessagePacket) packet;
mXmppConnectionService.markMessage( mXmppConnectionService.markMessage(
@ -739,8 +745,6 @@ public class XmppConnection implements Runnable {
} }
sendPacket(packet); sendPacket(packet);
} }
} catch (final NumberFormatException ignored) {
}
Log.d( Log.d(
Config.LOGTAG, Config.LOGTAG,
account.getJid().asBareJid() + ": online with resource " + account.getResource()); account.getJid().asBareJid() + ": online with resource " + account.getResource());