Re: Distributed Object validity
Re: Distributed Object validity
- Subject: Re: Distributed Object validity
- From: James Bucanek <email@hidden>
- Date: Tue, 15 Jan 2008 08:34:55 -0700
Jacob Bandes-Storch <mailto:email@hidden> wrote (Tuesday,
January 15, 2008 7:55 AM -0800):
I need a way (in both the pref pane and the application) to see if the
other one is still running. if (sharedobj) { ... seems not to work
correctly, it sometimes executes even if the app/prefpane is closed.
You have to define "invalid." If you send the object a
synchronous message, DO will return successfully if the message
was delivered and the executed. This doesn't tell you if your
remote object is "valid" (you'll have to figure that out
yourself), but it will tell you that the other process is
running and that the remote object accepted the message.
I'm also seeing "connection went invalid while waiting for a reply" in
the Console, but I can't figure out exactly when it shows up.
The "connection went invalid" is an exception that's thrown if
the DO communications fails. Just catch it and set a breakpoint
in your app. This will let you determine what message failed,
when, and where.
I my app, I have a deadman timer that periodically tickles my
server by sending it a dummy "isListening" message. This is a
synchronous method that (essentially) does nothing and returns
YES. I wrap the call in a try/catch and examine any exceptions
thrown by DO. This allows me to invalidate the connection and
attempt to restart or reconnect to the server if there's an
error. (As a general rule, I wrap all remote method calls in
try/catch handlers for this very reason.)
--
James Bucanek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden