• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problems with Distributed Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with Distributed Objects


  • Subject: Problems with Distributed Objects
  • From: Andreas Mayer <email@hidden>
  • Date: Wed, 25 Feb 2004 11:53:00 +0100

Hi all.

Since I'm not sure what my problem is (understanding or limitation of DO or a bug in my code) I'll first explain what I am trying to achive.

I want a client connect to a server and hand over an NSImage (actually a custom object that has an NSImage instance variable) for drawing in the server's context.

What _is_ working: Connecting to the server and handing over an object as reference (NSDistantObject).

What is _not_ working: Actually drawing the image and/or getting a copy (instead of a reference) of the object holding the image.

And this is what I have done:
- created a framework that holds my custom class(es)
- imported this framework in the server and the client
- defined a protocol for the server

From the protocol:

@protocol AMTiggerServerProtocol

- (oneway void)addSign:(bycopy in AMTickerSign *)aSign;

Server declaration:

@interface AMTiggerServer : NSObject <AMTiggerServerProtocol> {

In the client:

id theServer;
theServer = [NSConnection rootProxyForConnectionWithRegisteredName:@"AMTiggerServer" host:nil];
if (theServer) {
NSLog(@"connection established");
[theServer setProtocolForProxy:@protocol(AMTiggerServerProtocol)];


The implementation in the server (with debugging code):

- (void)addSign:(AMTickerSign *)aSign
{
[tickerView addSign:aSign];
NSLog(@"add sign with size: %f %f", [aSign size].width, [aSign size].height);
if ([aSign respondsToSelector:@selector(image)]) {
NSImage *theImage = [[aSign image] copy];
if (theImage) {
[imageView setImage:theImage];
NSLog(@"image: %@", theImage);
NSLog(@"---");
} else {
NSLog(@"no image?!");
}
} else {
NSLog(@"does not respond to image");
}
}

The size ([aSign size]) is correct. As a look with the debugger shows, I got an NSDistantObject. Why? I asked for a copy in the protocol. Do I need to implement any special methods in my class for bycopy to work? I implemented the NSCopying and the NSCoding protocols neither of which seem to be used.

After the NSLog(@"image: %@", theImage); (which works) the app crashes with a SIGBUS when releasing the autorelease pool. Why? Without this NSLog statement there is no crash.

The copy (NSImage *theImage = [[aSign image] copy];) does not help. I get a copy of the NSDistantObject. Is there a way to get the actual data of the object in question? I guess I could use NSArchiver ...

Besides my problem of getting a local copy - why does the drawing not work?

The AMTickerSign class implements

- (void)drawAtPoint:(NSPoint)point;
{
[image dissolveToPoint:point fraction:1.0];
}

When I send this message to my NSDistantObject, the method gets executed but nothing is drawn. Why?
(Drawing works when using an object from a plugin instead of the one from a remote client, so there shouldn't be a problem with the drawing code.)


I'm totally out of ideas right now, so any help would be greatly appreciated.


Regards, Andreas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Problems with Distributed Objects
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: Re: (Newbie) Prototypes don't seem to compile?
  • Next by Date: Tuning KVO validation.
  • Previous by thread: NSPopupButton query
  • Next by thread: Re: Problems with Distributed Objects
  • Index(es):
    • Date
    • Thread