Changeset 3661
- Timestamp:
- 01/29/06 02:28:14 (3 years ago)
- Files:
-
- WiredClient/trunk/WCChat.h (modified) (1 diff)
- WiredClient/trunk/WCChat.m (modified) (3 diffs)
- WiredClient/trunk/WCLink.h (modified) (1 diff)
- WiredClient/trunk/WCLink.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/WCChat.h
r3545 r3661 66 66 NSDate *_timestamp; 67 67 WCTopic *_topic; 68 69 BOOL _receivingPings; 70 NSTimeInterval _pingInterval; 68 71 } 69 72 WiredClient/trunk/WCChat.m
r3646 r3661 309 309 @"/topic", 310 310 @"/broadcast", 311 312 @"/benchmark", 313 @"/scan", 311 @"/ping", 314 312 NULL]; 315 313 } … … 439 437 } 440 438 #endif 439 else if([command isEqualToString:@"/ping"]) { 440 if(!_receivingPings) { 441 [[self connection] addObserver:self 442 selector:@selector(serverConnectionReceivedPing:) 443 name:WCServerConnectionReceivedPing]; 444 445 _receivingPings = YES; 446 } 447 448 _pingInterval = [NSDate timeIntervalSinceReferenceDate]; 449 450 [[self connection] sendCommand:WCPingCommand]; 451 452 return YES; 453 } 441 454 442 455 return NO; … … 645 658 646 659 [self validate]; 660 } 661 662 663 664 - (void)serverConnectionReceivedPing:(NSNotification *)notification { 665 NSTimeInterval interval; 666 667 interval = [NSDate timeIntervalSinceReferenceDate]; 668 669 [self printEvent:[NSSWF: 670 NSLS(@"Received ping reply after %.2fms", @"Ping received message (interval)"), 671 (interval - _pingInterval) * 1000.0]]; 672 673 [[self connection] removeObserver:self name:WCServerConnectionReceivedPing]; 674 675 _receivingPings = NO; 647 676 } 648 677 WiredClient/trunk/WCLink.h
r3525 r3661 32 32 WISocket *_socket; 33 33 WIURL *_url; 34 35 NSTimer *_pingTimer; 34 36 35 37 id _delegate; WiredClient/trunk/WCLink.m
r3659 r3661 65 65 66 66 - (void)dealloc { 67 NSLog(@"%@ dealloc", self); 68 67 69 [_url release]; 70 [_pingTimer release]; 68 71 69 72 [super dealloc]; … … 120 123 121 124 [WIThread detachNewThreadSelector:@selector(linkThread:) toTarget:self withObject:NULL]; 125 126 _pingTimer = [[NSTimer scheduledTimerWithTimeInterval:60.0 127 target:self 128 selector:@selector(pingTimer:) 129 userInfo:NULL 130 repeats:YES] retain]; 131 122 132 } 123 133 … … 127 137 _closing = YES; 128 138 _reading = NO; 139 140 [_pingTimer invalidate]; 129 141 } 130 142 … … 214 226 if(!_closing && _delegateLinkConnected) 215 227 [_delegate linkConnected:self]; 216 228 217 229 while(YES) { 218 230 if(!loopPool) … … 248 260 } 249 261 262 close: 250 263 [loopPool release]; 251 264 252 close:253 265 _reading = NO; 254 266 … … 272 284 } 273 285 286 287 288 - (void)pingTimer:(NSTimer *)timer { 289 [self sendCommand:WCPingCommand]; 290 } 291 274 292 @end
