Use notifications instead of old scheme for invalidation listening.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1079 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-03-06 14:48:59 +00:00
parent 4287219162
commit a3a7a895f7

View file

@ -2,6 +2,7 @@
#include "second-client.h"
#include <objects/Connection.h>
#include <objects/String.h>
#include <objects/Notification.h>
@implementation SecondServer
@ -34,14 +35,19 @@
- (Connection*) connection: ancestor didConnect: newConn
{
printf("New connection created\n");
[newConn registerForInvalidationNotification:self];
[newConn setDelegate:self];
printf(">>>>New connection 0x%x created\n", (unsigned)newConn);
[NotificationDispatcher
addObserver: self
selector: @selector(connectionBecameInvalid:)
name: ConnectionBecameInvalidNotification
object: newConn];
[newConn setDelegate: self];
return newConn;
}
- senderIsInvalid: sender
- connectionBecameInvalid: notification
{
id sender = [notification object];
if ([sender isKindOf:[Connection class]])
{
id remotes = [sender proxies];
@ -49,7 +55,7 @@
int arrayCount = [array count];
int i, j;
printf("Connection invalidated\n");
printf(">>> Connection 0x%x invalidated\n", (unsigned)sender);
/* This contortion avoids Array's calling -isEqual: on the proxy */
for (j = 0; j < remotesCount; j++)
@ -82,7 +88,11 @@ int main(int argc, char *argv[])
printf("Regsitered server object on localhost with name `secondserver'\n");
[c setDelegate:s];
[c registerForInvalidationNotification:s];
[NotificationDispatcher
addObserver: s
selector: @selector(connectionBecameInvalid:)
name: ConnectionBecameInvalidNotification
object: c];
[c runConnection];