Changeset 3118

Show
Ignore:
Timestamp:
02/06/06 23:45:58 (3 years ago)
Author:
timothy
Message:

Don't reuse the same AsyncSocket?. This lets us reliably reconnect.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cocoa-networking/Chat Core/MVIRCChatConnection.m

    r3117 r3118  
    296296- (id) init { 
    297297        if( ( self = [super init] ) ) { 
    298                 _chatConnection = [[AsyncSocket allocWithZone:nil] initWithDelegate:self]; 
    299  
    300298                _serverPort = 6667; 
    301299                _server = @"irc.freenode.net"; 
     
    371369        } 
    372370 
    373         [_lastConnectAttempt release]; 
     371        id old = _chatConnection; 
     372        _chatConnection = [[AsyncSocket allocWithZone:nil] initWithDelegate:self]; 
     373        [old setDelegate:nil]; 
     374        [old release]; 
     375 
     376        old = _lastConnectAttempt; 
    374377        _lastConnectAttempt = [[NSDate allocWithZone:nil] init]; 
     378        [old release]; 
    375379 
    376380        [self _willConnect]; // call early so other code has a chance to change our info 
     
    383387 
    384388        [self performSelector:@selector( _connect ) inThread:_connectionThread]; 
    385  
    386 /* 
    387 // Setup the proxy header with the most current connection address and port. 
    388         if( _proxy == MVChatConnectionHTTPSProxy || _proxy == MVChatConnectionHTTPProxy ) { 
    389                 NSString *userCombo = [NSString stringWithFormat:@"%@:%@", _proxyUsername, _proxyPassword]; 
    390                 NSData *combo = [userCombo dataUsingEncoding:NSASCIIStringEncoding]; 
    391  
    392                 g_free_not_null( _chatConnectionSettings -> proxy_string ); 
    393                 if( [combo length] > 1 ) { 
    394                         NSString *userCombo = [combo base64EncodingWithLineLength:0]; 
    395                         _chatConnectionSettings -> proxy_string = g_strdup_printf( "CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r\n", _chatConnectionSettings -> address, _chatConnectionSettings -> port, [userCombo UTF8String] ); 
    396                 } else _chatConnectionSettings -> proxy_string = g_strdup_printf( "CONNECT %s:%d HTTP/1.0\r\n\r\n", _chatConnectionSettings -> address, _chatConnectionSettings -> port ); 
    397  
    398                 g_free_not_null( _chatConnectionSettings -> proxy_string_after ); 
    399                 _chatConnectionSettings -> proxy_string_after = NULL; 
    400         } 
    401 */ 
    402389} 
    403390 
     
    766753        id old = _localUser; 
    767754        _localUser = nil; 
     755        [old release]; 
     756 
     757        old = _chatConnection; 
     758        _chatConnection = nil; 
     759        [old setDelegate:nil]; 
    768760        [old release]; 
    769761