Skip to content

Commit

Permalink
Check pubsub late subscription notification if relevant to this node,…
Browse files Browse the repository at this point in the history
… and don't block these events which don't have any items
  • Loading branch information
benlangfeld committed Oct 16, 2010
1 parent 2e34ec1 commit 777efb9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions TNPubSubNode.j
Expand Up @@ -592,22 +592,25 @@
- (BOOL)_didReceiveEvent:(TNStropheStanza)aStanza
{
var pubsubEvent = [aStanza firstChildWithName:@"event"];
if (_nodeName != [[pubsubEvent firstChildWithName:@"items"] valueForAttribute:@"node"])
return YES;

if ([pubsubEvent namespace] != Strophe.NS.PUBSUB_EVENT)
return YES;

if ([pubsubEvent containsChildrenWithName:@"subscription"])
{
var status = [[pubsubEvent firstChildWithName:@"subscription"] valueForAttribute:@"subscription"];
var subscription = [pubsubEvent firstChildWithName:@"subscription"],
status = [subscription valueForAttribute:@"subscription"],
nodeName = [subscription valueForAttribute:@"node"];

if (status === @"subscribed")
if (status === @"subscribed" && nodeName === _nodeName)
[[CPNotificationCenter defaultCenter] postNotificationName:TNStrophePubSubNodeSubscribedNotification object:self];

return YES;
}

if (_nodeName != [[pubsubEvent firstChildWithName:@"items"] valueForAttribute:@"node"])
return YES;

if (_delegate && [_delegate respondsToSelector:@selector(pubsubNode:receivedEvent:)])
[_delegate pubsubNode:self receivedEvent:aStanza];

Expand Down

0 comments on commit 777efb9

Please sign in to comment.