4

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.

Keith OYS
  • 2,285
  • 5
  • 32
  • 38
subharb
  • 3,374
  • 8
  • 41
  • 72
  • Im really lost with this one, any help will be appreciated. – subharb Jan 17 '12 at 08:34
  • Hi David, I am developing an application in which i need the functionality for group chat, currently i am able to do one-to-one chat. i am using XMPP classes . but i need group chat also. i know it will use XMPPRoom class. but i am unable to workout the code. please provide me some sample code for creating a unique chatroom and join a room. Thank you. – Naveen Jan 25 '12 at 07:21
  • can you post it as a question and provide me the link? I will take a look to my code meanwhile. – subharb Jan 26 '12 at 08:46
  • David here is the link of my question http://stackoverflow.com/questions/9032279/how-to-create-a-chat-room-using-xmpp-in-iphone – Naveen Jan 27 '12 at 11:33

2 Answers2

8

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];
subharb
  • 3,374
  • 8
  • 41
  • 72
0

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];
    ......
 }
tesmojones
  • 2,496
  • 2
  • 21
  • 40