سؤال

I'm using the XMPPFramework for iOS.

My problem is that when I join a room, then leave it, and join it again I get messages from that room, or private messages within that room twice, If I leave it and join it again I receive then 3 times, and so on.

I've been told that I might be registering multiple delegates and not removing them, but If I'm doing that I'm doing it accidentally and I'm not really sure where is this happening. Could anyone help finding where is this happening? Maybe an example would help me finding it in my code.

Thanks.

هل كانت مفيدة؟

المحلول

Just in case someone likes to know.

The right way to leave a room is to do this set of functions:

    [xmppRoom leaveRoom];
    [xmppRoom deactivate];
    [xmppRoom removeDelegate:self];

نصائح أخرى

I thing there is a problem with remoteTimestamp value. I solve the problem by add workaround in file: Extensions/XEP-0045/CoreDataStorage/XMPPRoomCoreDataStorage.m

before:

- (BOOL)existsMessage:(XMPPMessage *)message forRoom:(XMPPRoom *)room stream:(XMPPStream    *)xmppStream
{
    NSDate *remoteTimestamp = [message delayedDeliveryDate];

    if (remoteTimestamp == nil)
    {   
    return NO;
    }

    NSManagedObjectContext *moc = [self managedObjectContext];
    ......
}

after:

 - (BOOL)existsMessage:(XMPPMessage *)message forRoom:(XMPPRoom *)room stream:(XMPPStream *)xmppStream
{
    NSDate *remoteTimestamp = [message delayedDeliveryDate];

    if (remoteTimestamp == nil)
    {   
             return NO;
    }

    remoteTimestamp = nil;
    NSManagedObjectContext *moc = [self managedObjectContext];
    ......
 }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top