Skip to content

Commit c116663

Browse files
committed
Bug fix for edge case in XMPPStreamManagement - counts would be incorrect if a delegate filtered an incoming stanza.
1 parent 1c079ea commit c116663

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

Extensions/XEP-0198/XMPPStreamManagement.m

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,11 +1540,6 @@ - (void)maybeUpdateStoredLastHandledByClient
15401540
}
15411541
}
15421542

1543-
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender
1544-
{
1545-
1546-
}
1547-
15481543
- (void)xmppStream:(XMPPStream *)sender didSendIQ:(XMPPIQ *)iq
15491544
{
15501545
XMPPLogTrace();
@@ -1607,6 +1602,32 @@ - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)prese
16071602
}
16081603
}
16091604

1605+
/**
1606+
* This method is called if any of the xmppStream:willReceiveX: methods filter the incoming stanza.
1607+
*
1608+
* It may be useful for some extensions to know that something was received,
1609+
* even if it was filtered for some reason.
1610+
**/
1611+
- (void)xmppStreamDidFilterStanza:(XMPPStream *)sender
1612+
{
1613+
XMPPLogTrace();
1614+
1615+
if (isStarted)
1616+
{
1617+
// The element was filtered/consumed by something in the stack.
1618+
// So it is implicitly 'handled'.
1619+
1620+
XMPPStreamManagementIncomingStanza *stanza =
1621+
[[XMPPStreamManagementIncomingStanza alloc] initWithStanzaId:nil isHandled:YES];
1622+
[unackedByClient addObject:stanza];
1623+
1624+
if (![self maybeSendAck])
1625+
{
1626+
[self maybeUpdateStoredLastHandledByClient];
1627+
}
1628+
}
1629+
}
1630+
16101631
- (void)xmppStream:(XMPPStream *)sender didSendCustomElement:(NSXMLElement *)element
16111632
{
16121633
XMPPLogTrace();

0 commit comments

Comments
 (0)