• 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
Remote Invocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Remote Invocation


  • Subject: Remote Invocation
  • From: rajesh swarnkar <email@hidden>
  • Date: Tue, 10 Mar 2009 19:43:31 +0530

Hi All,
   I have two application in cocoa . My aim is to communicate with a
protocol between both the application using IPC mechanism (through
NSConnection) but I am unable to achieve my goal.

I want to use id < MyProtocol > protocol as inout parameter for two way
communication.
   Please see my code below and guide me what I am missing.

//***********************************Vendor
Process**********************************
    //           Root.h

@protocol MyProtocol

- (long) getNumber ;

@end


@protocol RootProtocol

- (HRESULT) getData : (id < MyProtocol >) pMyProtocol;

@end


@interface CRoot : NSObject < RootProtocol>

{}

@end


@protocol RemoteObjProtocol

- (id) GetDistObject;

@end

@interface CRootService : NSObject < RemoteObjProtocol >

{}

@end


@interface OutClass : NSObject < MyProtocol >

{}

@end


//               Root.m


@implementation OutClass

- (id) init {return self;}


- (void) dealloc {[super dealloc];}


- (long) getNumber {return 10;}


@end


@implementation CRoot

- (id) init{return self;}


- (void) dealloc{[super dealloc];}


- (HRESULT) getData : (id < MyProtocol >) pMyProtocol

{

pMyProtocol = [[[CRootService alloc] init] autorelease];

return S_OK;

}

@end


@implementation CRootService


- (id) init

{

[[NSConnection defaultConnection] setRootObject: self];

        [[NSConnection defaultConnection] registerName: @"RootService"];

return self;

}


- (void) dealloc{[super dealloc];}


- (id) GetDistObject

{

return [[[CRoot alloc] init] autorelease];

}


@end
//************************Reciever Process**************************

///  Test.h

@interface CTest : NSObject {}

+ (id) ReturnDistObj : (NSString*)registeredName;

@end


//             Test.m


id remoteProxy;


@implementation CTest

- (id) init{return self;}


- (void) dealloc{[super dealloc];}


+ (id) ReturnDistObj : (NSString*)registeredName

{

remoteProxy = [[NSConnection rootProxyForConnectionWithRegisteredName:
registeredName host: nil] retain];

 [remoteProxy setProtocolForProxy:@protocol(RemoteObjProtocol)];

 if (remoteProxy && [remoteProxy conformsToProtocol: @protocol(
RemoteObjProtocol)])

{

return [remoteProxy  GetDistObject] ;

}

else

return NULL;

}


@end

int main()
{

        id < RootProtocol > pRootProtocol = [CTest ReturnDistObj:
@"Rootservice"];

id < MyProtocol > pMyProtocol = nil;

[pRootProtocol getData: pMyProtocol ];

return 1;
}
_______________________________________________

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

  • Follow-Ups:
    • Re: Remote Invocation
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Getting Distant Object In C++
  • Next by Date: State of performing tasks with elevated privileges
  • Previous by thread: Re: Getting Distant Object In C++
  • Next by thread: Re: Remote Invocation
  • Index(es):
    • Date
    • Thread