Changeset 3945

Show
Ignore:
Timestamp:
03/23/06 20:47:06 (2 years ago)
Author:
morris
Message:

Don't terminate the connection when we get login failed, just close it

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCConnection.h

    r3673 r3945  
    128128 
    129129- (void)connect; 
    130 - (void)disconnect
     130- (void)close
    131131- (void)terminate; 
    132132 
  • WiredClient/trunk/WCLink.h

    r3673 r3945  
    4444        BOOL                                    _reading; 
    4545        BOOL                                    _closing; 
     46        BOOL                                    _terminating; 
    4647} 
    4748 
     
    5758 
    5859- (void)connect; 
    59 - (void)disconnect; 
     60- (void)close; 
     61- (void)terminate; 
    6062- (void)sendCommand:(NSString *)command; 
    6163- (void)sendCommand:(NSString *)command withArgument:(NSString *)argument1; 
  • WiredClient/trunk/WCLink.m

    r3713 r3945  
    117117- (void)connect { 
    118118        _reading = YES; 
    119         _closing = NO; 
     119        _terminating = NO; 
    120120 
    121121        [WIThread detachNewThreadSelector:@selector(linkThread:) toTarget:self withObject:NULL]; 
     
    131131 
    132132 
    133 - (void)disconnect
     133- (void)close
    134134        _closing = YES; 
     135        _reading = NO; 
     136} 
     137 
     138 
     139 
     140- (void)terminate { 
     141        _terminating = YES; 
    135142        _reading = NO; 
    136143} 
     
    217224                [_delegate linkConnected:self]; 
    218225         
    219         while(!_closing) { 
     226        while(!_closing && !_terminating) { 
    220227                if(!loopPool) 
    221228                        loopPool = [[NSAutoreleasePool alloc] init]; 
     
    224231                string = [_socket readStringUpToString:WCMessageSeparator encoding:NSUTF8StringEncoding timeout:1.0 error:&error]; 
    225232                 
    226                 if(_closing || (string && [string length] == 0)) { 
     233                if(_closing || _terminating || (string && [string length] == 0)) { 
    227234                        goto close; 
    228235                } 
     
    252259        [_pingTimer invalidate]; 
    253260                 
    254         if(_closing) { 
     261        if(_terminating) { 
    255262                if(_delegateLinkTerminated) 
    256263                        [_delegate linkTerminated:self]; 
  • WiredClient/trunk/WCServerConnection.m

    r3908 r3945  
    332332                nick = [bookmark objectForKey:WCBookmarksNick]; 
    333333                 
    334                 if([nick length] > 0) 
    335                         [_link sendCommand:WCNickCommand withArgument:nick]; 
     334                if([nick length] == 0) 
     335                        nick = [WCSettings objectForKey:WCNick]; 
     336                 
     337                [_link sendCommand:WCNickCommand withArgument:nick]; 
    336338 
    337339                status = [bookmark objectForKey:WCBookmarksStatus]; 
    338340                 
    339                 if([status length] > 0) 
    340                         [_link sendCommand:WCStatusCommand withArgument:status]; 
     341                if([status length] == 0) 
     342                        status = [WCSettings objectForKey:WCStatus]; 
     343 
     344                [_link sendCommand:WCStatusCommand withArgument:status]; 
    341345        } 
    342346} 
     
    361365         
    362366        if(_link && [_link isReading]) 
    363                 [_link disconnect]; 
     367                [_link terminate]; 
    364368        else 
    365369                [self postNotificationName:WCConnectionDidTerminate object:self]; 
     
    373377        [_link release]; 
    374378        _link = NULL; 
    375          
    376         if(!_loginFailed) 
    377                 [self autorelease]; 
    378379} 
    379380 
     
    385386        [_progressIndicator stopAnimation:self]; 
    386387         
    387         error = [[notification userInfo] objectForKey:WCErrorKey]; 
    388          
    389         if(error && [[self window] isVisible]) 
    390                 [[error alert] beginSheetModalForWindow:[self window]]; 
    391          
    392388        [_link release]; 
    393389        _link = NULL; 
    394390 
    395         if(![[self window] isVisible]) 
    396                 [self postNotificationName:WCServerConnectionTriggeredEvent eventTag:WCEventsServerDisconnected]; 
     391        if(!_loginFailed) { 
     392                error = [[notification userInfo] objectForKey:WCErrorKey]; 
     393                 
     394                if(error && [[self window] isVisible]) 
     395                        [[error alert] beginSheetModalForWindow:[self window]]; 
     396                 
     397                if(![[self window] isVisible]) 
     398                        [self postNotificationName:WCServerConnectionTriggeredEvent eventTag:WCEventsServerDisconnected]; 
     399        } 
    397400} 
    398401 
     
    412415                _loginFailed = YES; 
    413416                 
    414                 [_link disconnect]; 
     417                [_link close]; 
    415418        } 
    416419} 
     
    847850 
    848851 
    849 - (void)disconnect
    850         [_link disconnect]; 
     852- (void)close
     853        [_link close]; 
    851854} 
    852855 
  • WiredClient/trunk/WCTrackerConnection.m

    r3673 r3945  
    113113 
    114114        if(_link && [_link isReading]) 
    115                 [_link disconnect]; 
     115                [_link terminate]; 
    116116        else 
    117117                [self postNotificationName:WCConnectionDidTerminate object:self]; 
     
    315315 
    316316 
    317 - (void)disconnect
    318         [_link disconnect]; 
     317- (void)close
     318        [_link close]; 
    319319} 
    320320