🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
1 messages
1 total messages Started by Sharon Zakhour Wed, 30 Sep 1992 19:27
a new NeXTanswer on Distributed objects
#1699
Author: Sharon Zakhour
Date: Wed, 30 Sep 1992 19:27
53 lines
2438 bytes
Hope you find this useful!


detecting client death

Q:  How does a server that registers like:

[NXConnection registerRoot:self  withName: "myname"];

get notification of a client that has disconnected?  The delegate method  
connection:didConnect: will tell me when the client connects, but not when it  
disconnects.  Specifically, I want the server to know when a client application  
has been killed or crashed.

A:  In order to receive invalidation notification you must select the object  
that is to be notified and register it for invalidation notification.  This  
object then must conform to the NXSenderIsInvalid protocol.  For example, one  
of your server objects (probably the one that called registerRoot:withName:)  
should conform to the NXSenderIsInvalid protocol.  The method you need to  
implement to conform to this protocol is:  -senderIsInvalid:.  When the client  
connection dies, senderIsInvalid: will be called passing that connection.
	
You will also need to call worryAboutPortInvalidation (NXPort class method) --  
this will spawn a thread that will listen for a Port death and will message  
senderIsInvalid:.  The code would look something like:

NXConnection *primary = [NXConnection registerRoot: rootObj  withName: "foo"];
[primary setDelegate:self];
[NXPort worryAboutPortInvalidation];
[primary run];

Finally, in your connection:didConnect: delegate method you should call  
registerForInvalidationNotification:.  You should register on the second  
connection passed to this method.

Note:  The above information is assuming a non-AppKit program.  If you are  
using the AppKit, this notification mechanism is already in place.  Another  
important distinction is that in the AppKit case, there is not a separate  
thread, so there is less worrying that needs to be done about multi-threaded  
access.

See also:  The introduction to Distributed Objects which is online in:
GeneralRef/06_DistributedObjects/IntroDistObjects.rtf and the Distributed  
Objects release notes.

QAxx

Valid for 3.0


Sharon Zakhour
Developer Support 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads