Distributed Object, session behaviour problem

  • 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 on the server 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 my sample code from both server side and client side.

    /*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
previous month september 2007 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
Go to today