Distributed Object validity

  • I asked this question once, but didn't get an answer... hopefully
    someone can help out this time.

    I have a preference pane (I'm inclined to call it a preference pain at
    this point) and a helper application. I'm using distributed objects to
    communicate between them: <http://developer.apple.com/documentation/UserExperience/Conceptual/Preferen
    cePanes/Tasks/Communication.html#//apple_ref/doc/uid/20000708
    >

    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.
    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.

    Does anyone have any idea how to make this work? I appreciate the help.
  • Jacob Bandes-Storch <mailto:<jtbandes...> 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
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today