NSConnection died after some time on 10.8

19 views
Skip to first unread message

mandeep dhiman

unread,
Jan 30, 2013, 2:21:32 AM1/30/13
to cocoa-...@googlegroups.com
I'm using DO with for IPC. I used following code. Its working fine in 10.6 and 10.7 but on 10.8 die even both application were ideal.

NSConnection *connection =[NSConnection new];
[[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(connectionDidDie:)
                                                  name:NSConnectionDidDieNotification
                                                   object:nil];
[connection setRootObject:syncManager];  
if ([connection registerName:SYNC_SERVER_NAME] == NO){
       NSLog(@"Error registering server");
} 
- (void)connectionDidDie:(NSNotification *)aNotification{ 
     NSConnection     *deadConnection = [aNotification object];
     id    currentClient = [self.clientsList objectAtIndex:0];
     NS_DURING
     if([currentClient respondsToSelector:@selector(connectionForProxy)]) {
          if(deadConnection == [currentClient connectionForProxy]){
                 // remove proxy with dead connection
                 [clientsList removeObjectAtIndex:0];
                 NSLog(@"Removed client from client list.");
           }
     }
     NS_HANDLER
     [self.clientsList removeObjectAtIndex:0];
     NS_ENDHANDLER

}

// UI App

// ------
self.server = [NSConnection rootProxyForConnectionWithRegisteredName:SYNC_SERVER_NAME host:nil];
if(nil != self.server){
[[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(connectionDidDie:)
                                                     name:NSConnectionDidDieNotification
                                                   object:nil];
[self.server addMessageClient:self];
[self.server setProtocolForProxy:@protocol(MDMessageProtocol)];
//------

- (void)connectionDidDie:(NSNotification *)aNotification{
    NSLog(@"Error: Connection to server is broken");
}
Reply all
Reply to author
Forward
0 new messages