• 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
Distributed Objects nsproxy object problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Distributed Objects nsproxy object problem


  • Subject: Distributed Objects nsproxy object problem
  • From: NSTask <email@hidden>
  • Date: Sun, 23 Sep 2007 09:14:20 +0200

Hello all,

I have created a very simple program for using distributed objects.
The idea is quite simple. I am creating a server app which will talk to the
web-host and will receive and retain the session id. Now the client app
whichever is connected to server will asks for the session info, server will
pass them the session info.

Now my problem is whenever client receives the session info and try to
use it in their api for futher processing it always gets the error

 *** -[NSInvocation length]: selector not recognized [self = 0x30afc0]

While the same command used with the same session id on the server for the
same api works fine.
My doubt is it has got something to do wih target setting for the session
id.
Please advise, where and what I am missing.

After lot of digging on google and list I found this
http://theocacao.com/document.page/264
which is not working for me or I do not know where to fit this.


Here I am pasting mycode from both server side and client side. Please help.

/*main.c*/

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    MyMessageServer *server = [[MyMessageServer alloc] init];
    NSConnection *defaultConnection;
    defaultConnection = [NSConnection defaultConnection];

    [defaultConnection setRootObject:server];

    if ([defaultConnection registerName:@"server"] == NO) {
        NSLog(@"Failed to register name\n");
    }


    //[defaultConnection setDelegate:server];

    [[NSRunLoop currentRunLoop] configureAsServer];
    [[NSRunLoop currentRunLoop] run];

    [server release];
    [pool release];

    return 0;
    //return NSApplicationMain(argc,  (const char **) argv);
}

/*MyMessageServerProtocol.h*/
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

@protocol MyMessageServerProtocol

- (void)broadcastMessageString:(NSString *)aString
                sentFromClient:(id)aClient;

@end



/* MyMessageServer.h*/
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import "MyMessageServerProtocol.h"
#import <SOAPAPI/SOAPAPI.h>

@class SoapSession;
@interface MyMessageServer : NSObject <MyMessageServerProtocol> {
    SoapSession *_sess;
}

- (SoapSession *)login;

@end




/* MyMessageServer.m*/


#import "MyMessageServer.h"

@implementation MyMessageServer

- (void)broadcastMessageString:(NSString *)aString
                sentFromClient:(id)aClient
{
    if ([aString isEqualToString:@"login"]) {
        _sess = [self login];
    }

    NSLog(@"_sess:%@\n\n",_sess);

    [aClient performSelector:@selector(appendMessageString:)
                  withObject:_sess ];

    NSLog(@"Time from server:%@\n\n",[[_sess SOAPAPI] getCurrentTime]);
}

- (void) dealloc {
    [_myListOfClients release];
    _myListOfClients = nil;
    [super dealloc];
}

- (SoapSession *)login
{
    id _session = [[SoapSession alloc] initWithUserName:@"admin"
                                            andPassword:@"testpwd"
                                        andAppName:@"DO"
                                             andVersion:@"1.0"
                                            andHost:@"doHost"];
    return _session;

}


@end


===========================================
/*MyMasterController .m  -> Client Program*/

#import "MyMasterController.h"
#import <SOAPAPI/SOAPAPI.h>

@protocol MyMessageServerProtocol

- (void)broadcastMessageString:(NSString *)aString
sentFromClient:(id)aClient;

@end

@implementation MyMasterController


- (IBAction)sendMessage:(id)sender
{
    [server broadcastMessageString:[composeView string]
sentFromClient:self];
    [composeView setString:@""];
}

- (oneway void)appendMessageString:(id)response
{
    NSLog(@"current time on client:%@",[[response publicAPI]
getCurrentTime]);
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    server = [[NSConnection
rootProxyForConnectionWithRegisteredName:@"server" host:nil] retain];

    if (! server ) {
        NSLog(@"Error: Failed to connect to server.");
    } else {
        [server setProtocolForProxy:@protocol(MyMessageServerProtocol)];
        [server broadcastMessageString:@"login" sentFromClient:self];
    }

}

- (void)applicationWillTerminate:(NSNotification *)aNotification
{
    [server release];
    server = nil;
}

@end



/*****MyMasterController .h********/

#import <Cocoa/Cocoa.h>
#import <SOAPAPI/SOAPAPI.h>

@class SoapSession;
@interface MyMasterController : NSObject {
    IBOutlet NSTextView *composeView;
    IBOutlet NSTextView *messageView;
    id server;
}

- (IBAction)sendMessage:(id)sender;

- (oneway void)appendMessageString:(id)response;

@end
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: [MODERATOR] Do not discuss Leopard: was Core animation application compile error?
  • Next by Date: NSArrayController question
  • Previous by thread: Re: Core Data with Multiple Windows -- Example?
  • Next by thread: NSArrayController question
  • Index(es):
    • Date
    • Thread