Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 12-08-2005
steepLearningC steepLearningC is offline
Registered User
 
 
Join Date: Dec 2005
Posts: 3
retrieve proxy id

Hi there

I was wondering if there is an easy way to retrieve Proxy ids?

I am currently toying with the demos supplied with the Ice documentation and would like to do the following. While passing a clientproxy to a list on the server I would like to cout the id (used as username) of the proxy. The clientcode is as follows:

Code:
//code omitted

int
CallbackClient::run(int argc, char* argv[])
{	
	string username;
	//Enter Username tryblok begin
	try
	{
	    cout << "Enter Username.\n";

	    
	    cout << "Username: " << flush;
	    getline(cin, username);
	}
	catch(const Exception& ex)
	{
	    cerr << ex << endl;
	    return EXIT_FAILURE;
	}
	//Enter Username tryblok end

    PropertiesPtr properties = communicator()->getProperties();
    const char* proxyProperty = "Callback.Client.CallbackServer";
    std::string proxy = properties->getProperty(proxyProperty);
    if(proxy.empty())
    {
	cerr << appName() << ": property `" << proxyProperty << "' not set" << endl;
	
	return EXIT_FAILURE;
    }

    CallbackSenderPrx server = CallbackSenderPrx::checkedCast(communicator()->stringToProxy(proxy));
    if(!server)
    {
	cerr << appName() << ": invalid proxy" << endl;
	
	return EXIT_FAILURE;
    }

    ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client");
    Identity ident;
    ident.name = username;
    ident.category = "";
    CallbackReceiverPrx somevarname = CallbackReceiverPrx::uncheckedCast(adapter->add(new CallbackReceiverI, ident)); 

	
    adapter->activate();
    server->ice_connection()->setAdapter(adapter);

    server->addClient(somevarname);

//code omitted
on the server:

Code:
void
CallbackSenderI::addClient(const CallbackReceiverPrx& proxy, const Current& current)
{
    //pseudocode begin:
    // cout the username providet as identon the clientside:
    //CallbackReceiverPrx somevarname = CallbackReceiverPrx::uncheckedCast(adapter->add(new CallbackReceiverI, ident)); 
	//pseudocode end

_clients.push_back(proxy);

}
Reply With Quote
  #2 (permalink)  
Old 12-08-2005
matthew's Avatar
matthew matthew is online now
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,060
For support please fill out your signature information as described in this post Important note: Change in support policy
Reply With Quote
  #3 (permalink)  
Old 12-08-2005
steepLearningC steepLearningC is offline
Registered User
 
 
Join Date: Dec 2005
Posts: 3
Unhappy

I did, but after my initial post

Last edited by steepLearningC : 12-08-2005 at 10:13 PM.
Reply With Quote
  #4 (permalink)  
Old 12-08-2005
bernard's Avatar
bernard bernard is online now
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 816
You can extract the Ice::Identity from a proxy with ice_getIdentity(), e.g. prx->ice_getIdentity().

Since Ice 3.0.0, you can also "print" a proxy, e.g. cout << "My proxy: " << prx << endl.

Cheers,
Bernard
__________________
Bernard Normier
ZeroC, Inc.
Reply With Quote
  #5 (permalink)  
Old 12-08-2005
steepLearningC steepLearningC is offline
Registered User
 
 
Join Date: Dec 2005
Posts: 3
sweet 'n easy

thanx
Reply With Quote
  #6 (permalink)  
Old 12-09-2005
OrNot OrNot is offline
Registered User
 
Name: Bin.Li
Organization: GE Healthcare
Project: Enterprise solution
 
Join Date: Jun 2005
Location: Shanghai
Posts: 157
Send a message via MSN to OrNot
-->
hi,steepLearningC,
It seemed that you made some mistakes when using bi-dir connection. The ice document (page 916 , version 3.0.0)has given very detailed explanations about this. please refer to it.
You can get the identity via ice_getIdentity(), but you can't print it with
cout << "My proxy: " << prx << endl
since in your bi-dir case the proxy is a type of "fixed" ,which doesn't support unmarshalling.
I think Benard must overlook some lines of you codes .

Cheers
OrNot
__________________
Looking for the nails with my favorite hammer, ICE.
-------------------------------------------
Huo.Fei
GE Healthcare
Bin.Li@ge.com
--------------------------------------------
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ptr to Proxy w/o identity? bboerner Help Center 5 10-07-2005 11:39 AM
Ice Proxy Design jghickman Help Center 7 07-29-2005 09:00 PM
SSL Proxy Endpoint and -s gsalazar Help Center 11 06-22-2005 02:57 PM
Getting a description of proxy Nis Baggesen Help Center 2 06-01-2005 09:03 AM
Proxy to 127.0.0.1 Nis Baggesen Help Center 3 02-16-2005 05:04 PM


All times are GMT -4. The time now is 10:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.