Changeset 3585

Show
Ignore:
Timestamp:
02/21/07 14:44:09 (2 years ago)
Author:
jmmv
Message:

Get rid of the _knownRooms dictionary and instead make proper use of the
parent's _joinedRooms one. Fixes problems when rejoining previously-left
rooms either by an explicit part or by an "external" reason (such as a
kick).

OK'ed by timothy@.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Chat Core/MVICBChatConnection.m

    r3582 r3585  
    265265        NSParameterAssert( [identifier isKindOfClass:[NSString class]] ); 
    266266 
    267         NSString *uniqueIdentfier = [identifier lowercaseString]; 
    268         if( [uniqueIdentfier isEqualToString:[_room uniqueIdentifier]] ) 
    269                 return _room; 
    270  
    271         if( ! _knownRooms ) 
    272                 _knownRooms = [[NSMutableDictionary alloc] initWithCapacity:200]; 
    273  
    274         MVChatRoom *room = nil; 
    275         @synchronized( _knownRooms ) { 
    276                 room = [_knownRooms objectForKey:uniqueIdentfier]; 
    277                 if( room ) 
    278                         return room; 
    279  
    280                 room = [[MVICBChatRoom alloc] initWithName:identifier 
    281                                                                           andConnection:self]; 
    282                 if( room ) 
    283                         [_knownRooms setObject:room forKey:uniqueIdentfier]; 
    284         } 
    285  
    286         return [room autorelease]; 
     267        MVChatRoom *room; 
     268        @synchronized( _joinedRooms ) { 
     269                room = [self joinedChatRoomWithName:identifier]; 
     270                if( !room ) { 
     271                        room = [[MVICBChatRoom alloc] initWithName:identifier 
     272                                                                                  andConnection:self]; 
     273                        [self _addJoinedRoom:room]; 
     274                } 
     275        } 
     276        return room; 
    287277} 
    288278