What part of DO don't I understand?
What part of DO don't I understand?
- Subject: What part of DO don't I understand?
- From: Byron Wright <email@hidden>
- Date: Mon, 21 Feb 2005 18:45:02 -0800
So I am attempting to create a server in another thread that is
responsible for fetching data on a remote server. I want to collect the
data and then send it back to the main thread asynch. I am using
Distributed Objects to send the newly created data from the server
thread to the main thread. The issue I am having is that the newly
created objects (in the server thread) are always sent back to the main
thread as a proxy and not copied even though I have the bycopy hint in
the method sig. Here is the code I am using as a prototype to
understand DO, assume the connects have already been setup (which they
have).
//MyServer.h
@class Testobject;
@protocol MyServerMethods
- (oneway void) doSomework;
@end
@protocol MyClientMethods
- (oneway void) workDone : (in bycopy Testobject *) obj;
- (void) setServer: (id) server;
@end
@interface MyServer : NSObject <MyServerMethods>
{
id clientProxy;
}
- (id) initWithClient: (id) client;
- (oneway void) doSomework;
+ (void)connectWithPorts:(NSArray *)portArray;
@end
/
/-----------------------------------------------------------------------
-
//myClient.h
@interface MyClient : NSObject <MyClientMethods> {
id<MyServerMethods> myServer ;
NSConnection* kitConnection;
}
- (IBAction) doWork: (id) sender;
- (void) setServer: (id) server;
- (oneway void) workDone : (in bycopy Testobject *) obj;
- (void) createServer;
@end
/
/-----------------------------------------------------------------------
-
so my server does some work then sends a new object to the main thread
(MyClient)
so my client called doSomework from the main thread.
- (oneway void) doSomework
{
int total = 1000;
int it = 0;
for(it ; it < total; ++it)
{
NSLog(@"doSomework %i",it);
}
Testobject * obj = [[Testobject alloc] init];
//done send back to main thread
[clientProxy workDone:obj ];
//[obj release];
}
MyClient then accepts the new data :
- (oneway void) workDone : (in bycopy Testobject *) obj;
{
NSLog(@"myClient:workDone");
if([obj isProxy])
{
NSLog(@"I am baffled");
}
NSLog(@"obj = %@",[obj description]);
}
problem is obj isProxy is always true. Also, something else I found out
the hard way, NSLog(@"obj = %@",obj) always crashes if it's an NSProxy,
I am guessing because NSProxy does not know how to dispatch this call?
here is the simple data object I am using for testing:
@interface Testobject : NSObject <NSCoding>{
NSString * val;
}
- (NSString *)val;
- (void)setVal:(NSString *)aVal;
@end
Any help is always appreciated.
Cheers,
Byron
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden