Skip to content

Commit 1385b09

Browse files
committed
Adding new delegate method for XMPPStream - xmppStreamDidFilterStanza
1 parent 78af4b3 commit 1385b09

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

Core/XMPPStream.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,14 @@ extern const NSTimeInterval XMPPStreamTimeoutNone;
940940
- (XMPPMessage *)xmppStream:(XMPPStream *)sender willReceiveMessage:(XMPPMessage *)message;
941941
- (XMPPPresence *)xmppStream:(XMPPStream *)sender willReceivePresence:(XMPPPresence *)presence;
942942

943+
/**
944+
* This method is called if any of the xmppStream:willReceiveX: methods filter the incoming stanza.
945+
*
946+
* It may be useful for some extensions to know that something was received,
947+
* even if it was filtered for some reason.
948+
**/
949+
- (void)xmppStreamDidFilterStanza:(XMPPStream *)sender;
950+
943951
/**
944952
* These methods are called after their respective XML elements are received on the stream.
945953
*
@@ -1093,7 +1101,7 @@ extern const NSTimeInterval XMPPStreamTimeoutNone;
10931101
* The standard example is XEP-0198, which uses <r> & <a> elements.
10941102
*
10951103
* If you're using custom elements, you must register the custom element name(s).
1096-
* Otherwise the xmppStream will treat an non-XMPP elements as errors (xmppStream:didReceiveError:).
1104+
* Otherwise the xmppStream will treat non-XMPP elements as errors (xmppStream:didReceiveError:).
10971105
*
10981106
* @see registerCustomElementNames (in XMPPInternal.h)
10991107
**/

Core/XMPPStream.m

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,15 +2830,16 @@ - (void)receiveIQ:(XMPPIQ *)iq
28302830
}});
28312831
}
28322832

2833-
if (modifiedIQ)
2834-
{
2835-
dispatch_async(xmppQueue, ^{ @autoreleasepool {
2836-
2837-
if (state == STATE_XMPP_CONNECTED) {
2833+
dispatch_async(xmppQueue, ^{ @autoreleasepool {
2834+
2835+
if (state == STATE_XMPP_CONNECTED)
2836+
{
2837+
if (modifiedIQ)
28382838
[self continueReceiveIQ:modifiedIQ];
2839-
}
2840-
}});
2841-
}
2839+
else
2840+
[multicastDelegate xmppStreamDidFilterStanza:self];
2841+
}
2842+
}});
28422843
}});
28432844
}
28442845
}
@@ -2904,15 +2905,16 @@ - (void)receiveMessage:(XMPPMessage *)message
29042905
}});
29052906
}
29062907

2907-
if (modifiedMessage)
2908-
{
2909-
dispatch_async(xmppQueue, ^{ @autoreleasepool {
2910-
2911-
if (state == STATE_XMPP_CONNECTED) {
2908+
dispatch_async(xmppQueue, ^{ @autoreleasepool {
2909+
2910+
if (state == STATE_XMPP_CONNECTED)
2911+
{
2912+
if (modifiedMessage)
29122913
[self continueReceiveMessage:modifiedMessage];
2913-
}
2914-
}});
2915-
}
2914+
else
2915+
[multicastDelegate xmppStreamDidFilterStanza:self];
2916+
}
2917+
}});
29162918
}});
29172919
}
29182920
}
@@ -2978,15 +2980,16 @@ - (void)receivePresence:(XMPPPresence *)presence
29782980
}});
29792981
}
29802982

2981-
if (modifiedPresence)
2982-
{
2983-
dispatch_async(xmppQueue, ^{ @autoreleasepool {
2984-
2985-
if (state == STATE_XMPP_CONNECTED) {
2983+
dispatch_async(xmppQueue, ^{ @autoreleasepool {
2984+
2985+
if (state == STATE_XMPP_CONNECTED)
2986+
{
2987+
if (modifiedPresence)
29862988
[self continueReceivePresence:presence];
2987-
}
2988-
}});
2989-
}
2989+
else
2990+
[multicastDelegate xmppStreamDidFilterStanza:self];
2991+
}
2992+
}});
29902993
}});
29912994
}
29922995
}

0 commit comments

Comments
 (0)