void ConnectRequestHandler::setConnection(const Ice::ConnectionIPtr& connection, bool compress) { { Lock sync(*this); assert(!_exception && !_connection); _connection = connection; _compress = compress; } // // If this proxy is for a non-local object, and we are using a router, then // add this proxy to the router info object. // RouterInfoPtr ri = _reference->getRouterInfo(); if(ri && !ri->addProxy(_proxy, ICE_SHARED_FROM_THIS)) { return; // The request handler will be initialized once addProxy returns. } // // We can now send the queued requests. // flushRequests(); }
void ConnectRequestHandler::setConnection(const Ice::ConnectionIPtr& connection, bool compress) { { Lock sync(*this); assert(!ICE_EXCEPTION_GET(_exception) && !_connection); _connection = connection; _compress = compress; } // // If this proxy is for a non-local object, and we are using a router, then // add this proxy to the router info object. // RouterInfoPtr ri = _reference->getRouterInfo(); #ifdef ICE_CPP11_MAPPING if(ri && !ri->addProxy(_proxy, dynamic_pointer_cast<AddProxyCallback>(shared_from_this()))) #else if(ri && !ri->addProxy(_proxy, this)) #endif { return; // The request handler will be initialized once addProxy returns. } // // We can now send the queued requests. // flushRequests(); }
ConnectionRequestHandler::ConnectionRequestHandler(const ReferencePtr& reference, const Ice::ObjectPrx& proxy) : RequestHandler(reference) { _connection = _reference->getConnection(_compress); RouterInfoPtr ri = reference->getRouterInfo(); if(ri) { ri->addProxy(proxy); } }
RouterPrxPtr ICE_OBJECT_PRX::ice_getRouter() const { RouterInfoPtr ri = _reference->getRouterInfo(); #ifdef ICE_CPP11_MAPPING return ri ? ri->getRouter() : nullptr; #else return ri ? ri->getRouter() : RouterPrxPtr(); #endif }
void IceInternal::OutgoingConnectionFactory::setRouterInfo(const RouterInfoPtr& routerInfo) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); if(_destroyed) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } assert(routerInfo); // // Search for connections to the router's client proxy endpoints, // and update the object adapter for such connections, so that // callbacks from the router can be received over such // connections. // ObjectAdapterPtr adapter = routerInfo->getAdapter(); vector<EndpointIPtr> endpoints = routerInfo->getClientEndpoints(); for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) { EndpointIPtr endpoint = *p; // // Modify endpoints with overrides. // if(_instance->defaultsAndOverrides()->overrideTimeout) { endpoint = endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue); } // // The Connection object does not take the compression flag of // endpoints into account, but instead gets the information // about whether messages should be compressed or not from // other sources. In order to allow connection sharing for // endpoints that differ in the value of the compression flag // only, we always set the compression flag to false here in // this connection factory. // endpoint = endpoint->compress(false); for(multimap<ConnectorPtr, ConnectionIPtr>::const_iterator q = _connections.begin(); q != _connections.end(); ++q) { if(q->second->endpoint() == endpoint) { q->second->setAdapter(adapter); } } } }
bool IceInternal::RouterInfo::addProxy(const Ice::ObjectPrxPtr& proxy, const AddProxyCallbackPtr& callback) { assert(proxy); { IceUtil::Mutex::Lock sync(*this); if(_identities.find(proxy->ice_getIdentity()) != _identities.end()) { // // Only add the proxy to the router if it's not already in our local map. // return true; } } Ice::ObjectProxySeq proxies; proxies.push_back(proxy); AddProxyCookiePtr cookie = new AddProxyCookie(callback, proxy); #ifdef ICE_CPP11_MAPPING RouterInfoPtr self = this; _router->addProxies_async(proxies, [self, cookie](const Ice::ObjectProxySeq& proxies) { self->addProxyResponse(proxies, cookie); }, [self, cookie](exception_ptr e) { try { rethrow_exception(e); } catch(const Ice::Exception& ex) { self->addProxyException(ex, cookie); } }); #else _router->begin_addProxies(proxies, newCallback_Router_addProxies(this, &RouterInfo::addProxyResponse, &RouterInfo::addProxyException), cookie); #endif return false; }
void IceInternal::RouterInfo::getClientEndpoints(const GetClientEndpointsCallbackPtr& callback) { vector<EndpointIPtr> clientEndpoints; { IceUtil::Mutex::Lock sync(*this); clientEndpoints = _clientEndpoints; } if(!clientEndpoints.empty()) { callback->setEndpoints(clientEndpoints); return; } #ifdef ICE_CPP11_MAPPING RouterInfoPtr self = this; _router->getClientProxy_async( [self, callback](const Ice::ObjectPrxPtr& proxy) { self->getClientProxyResponse(proxy, callback); }, [self, callback](exception_ptr e) { try { rethrow_exception(e); } catch(const Ice::Exception& ex) { self->getClientProxyException(ex, callback); } }); #else _router->begin_getClientProxy(newCallback_Router_getClientProxy(this, &RouterInfo::getClientProxyResponse, &RouterInfo::getClientProxyException), callback); #endif }