mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
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:
parent
2cee53fe1c
commit
72d1e52e76
1 changed files with 16 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "second-client.h"
|
#include "second-client.h"
|
||||||
#include <objects/Connection.h>
|
#include <objects/Connection.h>
|
||||||
#include <objects/String.h>
|
#include <objects/String.h>
|
||||||
|
#include <objects/Notification.h>
|
||||||
|
|
||||||
@implementation SecondServer
|
@implementation SecondServer
|
||||||
|
|
||||||
|
@ -34,14 +35,19 @@
|
||||||
|
|
||||||
- (Connection*) connection: ancestor didConnect: newConn
|
- (Connection*) connection: ancestor didConnect: newConn
|
||||||
{
|
{
|
||||||
printf("New connection created\n");
|
printf(">>>>New connection 0x%x created\n", (unsigned)newConn);
|
||||||
[newConn registerForInvalidationNotification:self];
|
[NotificationDispatcher
|
||||||
[newConn setDelegate:self];
|
addObserver: self
|
||||||
|
selector: @selector(connectionBecameInvalid:)
|
||||||
|
name: ConnectionBecameInvalidNotification
|
||||||
|
object: newConn];
|
||||||
|
[newConn setDelegate: self];
|
||||||
return newConn;
|
return newConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
- senderIsInvalid: sender
|
- connectionBecameInvalid: notification
|
||||||
{
|
{
|
||||||
|
id sender = [notification object];
|
||||||
if ([sender isKindOf:[Connection class]])
|
if ([sender isKindOf:[Connection class]])
|
||||||
{
|
{
|
||||||
id remotes = [sender proxies];
|
id remotes = [sender proxies];
|
||||||
|
@ -49,7 +55,7 @@
|
||||||
int arrayCount = [array count];
|
int arrayCount = [array count];
|
||||||
int i, j;
|
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 */
|
/* This contortion avoids Array's calling -isEqual: on the proxy */
|
||||||
for (j = 0; j < remotesCount; j++)
|
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");
|
printf("Regsitered server object on localhost with name `secondserver'\n");
|
||||||
|
|
||||||
[c setDelegate:s];
|
[c setDelegate:s];
|
||||||
[c registerForInvalidationNotification:s];
|
[NotificationDispatcher
|
||||||
|
addObserver: s
|
||||||
|
selector: @selector(connectionBecameInvalid:)
|
||||||
|
name: ConnectionBecameInvalidNotification
|
||||||
|
object: c];
|
||||||
|
|
||||||
[c runConnection];
|
[c runConnection];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue