Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Distributed Object validity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Distributed Object validity



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


References: 
 >Distributed Object validity (From: Jacob Bandes-Storch <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.