Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resend the unacked stanzaIds by the server #637

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Extensions/XEP-0198/XMPPStreamManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@
- (void)xmppStreamManagement:(XMPPStreamManagement *)sender wasEnabled:(NSXMLElement *)enabled;
- (void)xmppStreamManagement:(XMPPStreamManagement *)sender wasNotEnabled:(NSXMLElement *)failed;


/**
* Resend the stanzaIds not acked by the server
*
* @param stanzaIds Includes all "stanzaIds" of sent elements that were not acked by the server.
*/
- (void)xmppStreamManagement:(XMPPStreamManagement *)sender shouldResendStanzaIds:(NSArray *)stanzaIds;


/**
* Notifies delegates that a request <r/> for an ack from the server was sent.
**/
Expand Down
22 changes: 21 additions & 1 deletion Extensions/XEP-0198/XMPPStreamManagement.m
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,27 @@ - (void)processResumed:(NSXMLElement *)resumed
(unsigned long)[prev_unackedByServer count]);

diff = (uint32_t)[prev_unackedByServer count];
}
}
else if (diff < [prev_unackedByServer count])
{
//Resend All unacked stanzaIds by Server
NSUInteger offset = [prev_unackedByServer count] - diff;

NSMutableArray *resendIds = [NSMutableArray array];

for (NSUInteger i = offset; i > 0; i--)
{
NSUInteger index = [prev_unackedByServer count] - i;
XMPPStreamManagementOutgoingStanza *outgoingStanza = prev_unackedByServer[index];

if (outgoingStanza.stanzaId) {
[resendIds addObject:outgoingStanza.stanzaId];
}
}
[multicastDelegate xmppStreamManagement:self shouldResendStanzaIds:resendIds];

}


NSMutableArray *stanzaIds = [NSMutableArray arrayWithCapacity:(NSUInteger)diff];

Expand Down
25 changes: 25 additions & 0 deletions emocache
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<mxfile host="app.diagrams.net" modified="2022-03-02T01:49:44.756Z" agent="5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36" etag="Y4RhWjVKBkW_E4sgIMQH" version="16.6.4" type="github">
<diagram id="9mt0mT-YvvhotbRE0Y7R" name="Page-1">
<mxGraphModel dx="1106" dy="584" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="lkxyvxAMdHjxNUkUOwrN-1" value="config" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;" vertex="1" parent="1">
<mxGeometry x="340" y="240" width="140" height="150" as="geometry" />
</mxCell>
<mxCell id="lkxyvxAMdHjxNUkUOwrN-2" value="http" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;" vertex="1" parent="lkxyvxAMdHjxNUkUOwrN-1">
<mxGeometry y="30" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="lkxyvxAMdHjxNUkUOwrN-5" value="http" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;" vertex="1" parent="lkxyvxAMdHjxNUkUOwrN-1">
<mxGeometry y="60" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="lkxyvxAMdHjxNUkUOwrN-3" value="Item 2" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;" vertex="1" parent="lkxyvxAMdHjxNUkUOwrN-1">
<mxGeometry y="90" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="lkxyvxAMdHjxNUkUOwrN-4" value="Item 3" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;" vertex="1" parent="lkxyvxAMdHjxNUkUOwrN-1">
<mxGeometry y="120" width="140" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>