What is wrong with my code (was : Distant DO)
What is wrong with my code (was : Distant DO)
- Subject: What is wrong with my code (was : Distant DO)
- From: kubernan <email@hidden>
- Date: Wed, 19 Jun 2002 13:58:08 +0200
Hello,
Can you hep me before i'm going crazy ?
My client app can establish a communication to my remote server. During
the server work
i'd like to send some feedbacks to the client about its work. I have
some problems for doing that.
After establishing a connection to the server, the client sends its
proxy got from the server.
When the server needs to send feedback to this client, it uses the
proxy. But it doesn't
work in my app.
Please not i do not add some inits or declaration in the sample code
bellow.
Client part :
// Work done in a detached thread
... blabla ...
serverConn = [[NSConnection alloc] initWithReceivePort:(NSPort
*)[[sendPort class] port] sendPort:sendPort];
proxyObj = [serverConn rootProxy];
NS_HANDLER
proxyObj = nil;
NS_ENDHANDLER
if (nil == proxyObj) {
NSLog(@"client: getting proxy failed\n");
exit(1);
}
[serverConn enableMultipleThreads];
[(NSDistantObject *)proxyObj
setProtocolForProxy:@protocol(ServerImplement)];
[proxyObj registerFeedbackClient:proxyObj
withName:aString]; //<- sending the client proxy object, it works
reply = [proxyObj serverWork:data_for_server]; // <- It works
-(void) feedbackClient:(NSString*)t // receives the server pings.
Doesn't work.
{
NSLog(t);
}
Server Part
// Register the proxy under an unique name in a NSMutableDictionnary
(that is retain)
-(void)registerFeedbackClient:(id)newClient withName:(NSString*)name
{
[lockArrayUpdate lock];
[remoteClient setObject: newClient forKey:name];
[lockArrayUpdate unlock];
NSLog(@"Get it"); // <- this message is displayed.
}
- (NSMutableDictionary *) serverWork:(id) sender
{
id connectionClient;
// Do some work
//...
// Here i want to send feedback to the client
connectionClient = [remoteClient objectForKey:name]; <- read the
appropriate proxy
[(NSDistantObject *)connectionClient setProtocolForProxy:
@protocol(clientImplement)];
[connectionClient feedbackClient:@"hello"]; <- A client method :
the hello doen't appear in the log : crash.
// End of feedback
// End of the work
[returnTheArray setObject:@"WORK FINISHED" forKey:@"myAppResult"];
return [[returnTheArray copy] autorelease];// <- It works if i
comment the feedback code.
}
Now i have this result during the execution :
Server log : Get it
*** -[NSConnection setProtocolForProxy:]: selector not recognized
Client log : An uncaught exception was raised
*** -[NSConnection setProtocolForProxy:]: selector not recognized
*** Uncaught exception: <NSInvalidArgumentException>
*** -[NSConnection setProtocolForProxy:]: selector not recognized
Any idea ?
_______________________________________________
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.