Can I Get the object's DirectProxy?

ggslayerggslayer Member MingYi ZhangOrganization: renren.comProject: renren data platform
Hi,
Can I get the directproxy of a object from the icegridregistry?

I called the findallreplica and I got a list of indirect proxies. And I want the proxies with ip and port with out call to ice_getConnection(which will create a connection to server, this is not my wanner)

thanks!

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    You need to use the Ice::Locator interface directly to resolve the endpoints of the adapter IDs of each indirect proxy.

    For example:
    // C++
    Ice::Identity myIdentity = ...;
    Ice::ObjectPrxSeq proxies = query->findAllReplicas(myIdentity);
    Ice::LocatorPrx locator = query->ice_getCommunicator()->getDefaultLocator();
    Ice::ObjectPrxSeq directProxies;
    for(Ice::ObjectPrxSeq::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
    {
        try
        {
            Ice::ObjectPrx directProxy = locator->findAdapterById((*p)->ice_getAdapterId());
            directProxies.push_back((*p)->ice_endpoints(directProxy->ice_getEndpoints()));
        }
        catch(std::exception& ex)
        {
            // Handle exception
        }
    }
    

    In the code above, the directProxies sequence will contain a list of direct proxies for each of the replicas. Note that this will cause the activation of all the replicas if necessary.

    Cheers,
    Benoit.
  • ggslayerggslayer Member MingYi ZhangOrganization: renren.comProject: renren data platform
    thank you!
Sign In or Register to comment.