View Single Post
  #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