Distributed Objects - bycopy

  • I wrote a client/server application that relies on Distributed Objects
    to communicate.
    I'm extensively using bycopy since I want all data to be transfered at
    once thus preventing
    series of forwarded method calls etc.

    But, I figured out that the object received by the client where not
    actually copied (when debugging I can the they're nsdistantobject or
    something like that...)
    And every call is forwarded to the server
    for example, my protocol has methods like this:

    - (bycopy NSDictionary *)aMethodThatReturnsADictionary;

    the implementation would be :

    - (bycopy NSDictionary *)aMethodThatReturnsADictionary
    {
    return [ NSDictionary dictionaryWithObjectsAndKeys: @"Hello",
    @"World", nil ];
    }

    Am I having the expected behaviour, or did I missed something?

    Regards
  • I've had a similar experience and ended up implementing -
    replacementObjectForPortCoder: for the classes which I wanted to send
    bycopy.

    I believe NSObject's implementation looks something like

    - (id) replacementObjectForPortCoder:(NSPortCoder *)coder
      { return [NSDistantObject proxyWithLocal:self connection:[coder
    connection]]; }

    while arguably it should look like

    - (id) replacementObjectForPortCoder:(NSPortCoder *)coder
      {
        if ([coder isBycopy])
          return self;
        return [NSDistantObject proxyWithLocal:self connection:[coder
    connection]];
      }

    Cheers,
    dave

    On 16-Jan-08, at 7:12 AM, Half Activist wrote:

    > I wrote a client/server application that relies on Distributed
    > Objects to communicate.
    > I'm extensively using bycopy since I want all data to be transfered
    > at once thus preventing
    > series of forwarded method calls etc.
    >
    > But, I figured out that the object received by the client where not
    > actually copied (when debugging I can the they're nsdistantobject or
    > something like that...)
    > And every call is forwarded to the server
    > for example, my protocol has methods like this:
    >
    > - (bycopy NSDictionary *)aMethodThatReturnsADictionary;
    >
    > the implementation would be :
    >
    > - (bycopy NSDictionary *)aMethodThatReturnsADictionary
    > {
    > return [ NSDictionary dictionaryWithObjectsAndKeys: @"Hello",
    > @"World", nil ];
    > }
    >
    > Am I having the expected behaviour, or did I missed something?
    >
    > Regards
  • On Wednesday, January 16, 2008, at 08:20AM, "David Spooner" <dave...> wrote:
    > I've had a similar experience and ended up implementing -
    > replacementObjectForPortCoder: for the classes which I wanted to send
    > bycopy.

    The OP mentioned NSDictionary, so be careful if you add that as a category on Apple's classes!  It's also important to note that NSPortCoder doesn't support keyed archiving, so your encodeWithCoder: and initWithCoder: methods have to test for allowsKeyedCoding.

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