本文整理汇总了C++中ice::CommunicatorPtr::stringToProxy方法的典型用法代码示例。如果您正苦于以下问题:C++ CommunicatorPtr::stringToProxy方法的具体用法?C++ CommunicatorPtr::stringToProxy怎么用?C++ CommunicatorPtr::stringToProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::CommunicatorPtr
的用法示例。
在下文中一共展示了CommunicatorPtr::stringToProxy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitialzieICE
/// @brief initialize ICE run time
/// @todo multi-thread scenario
/// @todo to call ic->destroy()
void MyICE::InitialzieICE(){
static char* endpoint=NULL;
try{
int argc = 1;
char **argv = new char*[1];
argv[0]=new char[1];
strcpy_s(argv[0],1,"");
Ice::CommunicatorPtr ic = Ice::initialize(argc, argv);
if (endpoint==NULL){
int clen=0;
endpoint = _6bees_net::GetDataByHTTP(epurl,clen);
//endpoint = "UUICE:tcp -h 118.123.7.85 -p 9090 -t 9000 -z";
if (endpoint==NULL){
UUDEBUG((LOG_ERROR,"Cannot connect to endpoint URL."));
return;
}else{
Ice::ObjectPrx base = ic->stringToProxy(endpoint);
_user = UUTOOLBAR::UserPrx::checkedCast(base);
}
}else{
Ice::ObjectPrx base = ic->stringToProxy(endpoint);
_user = UUTOOLBAR::UserPrx::checkedCast(base);
}
}catch(const Ice::Exception& e){
const char* s = e.what();
UUDEBUG((LOG_ERROR,s));
}catch (...) {
UUDEBUG((LOG_ERROR,"ICE unexpected error!"));
}
}
示例2: test
void
allTestsWithTarget(const Ice::CommunicatorPtr& comm)
{
RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle);
AdminPrx admin = session->getAdmin();
test(admin);
cout << "testing targets... " << flush;
TestIntfPrx obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));
obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));
obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));
obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));
obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));
test(obj->getProperty("TargetProp") == "1");
cout << "ok" << endl;
session->destroy();
}
示例3:
pointcloudClient::pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix, std::string proxy)
{
this->newData=false;
this->prefix=prefix;
Ice::PropertiesPtr prop;
prop = ic->getProperties();
this->refreshRate=0;
int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",10);
this->cycle=(float)(1/(float)fps)*1000000;
try{
Ice::ObjectPrx basePointCloud = ic->stringToProxy(proxy);
if (0==basePointCloud){
throw prefix + " Could not create proxy";
}
else {
this->prx = jderobot::pointCloudPrx::checkedCast(basePointCloud);
if (0==this->prx)
throw "Invalid proxy" + prefix;
}
}catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
throw "Invalid proxy" + prefix;
}
catch (const char* msg) {
std::cerr << msg << std::endl;
jderobot::Logger::getInstance()->error(prefix + " Not camera provided");
throw "Invalid proxy" + prefix;
}
_done=false;
this->pauseStatus=false;
}
示例4: test
Test::PriorityPrx
allTests(const Ice::CommunicatorPtr& communicator)
{
cout << "testing server priority... " << flush;
string ref = "test:default -p 12010 -t 10000";
Ice::ObjectPrx base = communicator->stringToProxy(ref);
test(base);
Test::PriorityPrx priority = Test::PriorityPrx::checkedCast(base);
try
{
#ifdef _WIN32
test(1 == priority->getPriority());
#else
test(50 == priority->getPriority());
#endif
}
catch(...)
{
test(false);
}
cout << "ok" << endl;
return priority;
}
示例5: test
void
testUOE(const Ice::CommunicatorPtr& communicator)
{
string ref = "uoet:default -p 12010";
Ice::ObjectPrx base = communicator->stringToProxy(ref);
test(base);
UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrx::uncheckedCast(base);
test(uoet);
try
{
uoet->op();
test(false);
}
catch(const Ice::UnexpectedObjectException& ex)
{
test(ex.type == "::Test::AlsoEmpty");
test(ex.expectedType == "::Test::Empty");
}
catch(const Ice::Exception& ex)
{
cout << ex << endl;
test(false);
}
catch(...)
{
test(false);
}
}
示例6: mos_init
void* mos_init(void *p)
{
vuser_node_st_t *pVuser = (vuser_node_st_t*)p;
bench_t *bp = (bench_t *)pVuser->b->b;
mos_st *ap = (mos_st *)malloc(sizeof(mos_st));
pVuser->verb = ap;
srand(time(0));
create_transaction(pVuser,"MOS");
int status = 0;
Ice::CommunicatorPtr ic;
try{
ic = Ice::initialize();
Ice::ObjectPrx base = ic->stringToProxy("mosInterfaceAdapter:default -h 10.249.65.38 -p 40001");
MOSInterfacePrx mos = MOSInterfacePrx::checkedCast(base);
if(!mos){
throw "Invalid proxy";
}
ap->mos = new MOSInterfacePrx(mos);
ap->ic = new Ice::CommunicatorPtr(ic);
}catch(const Ice::Exception& ex){
cerr << ex << endl;
status = 1;
}catch(const char* msg){
cerr << msg << endl;
status = 1;
}
}
示例7: enroll
//chunkserver enroll
int MasterDaemon::enroll()
{
static int init = 0;
try{
if (init==0){
Ice::CommunicatorPtr ic = Ice::initialize();
Ice::ObjectPrx base = ic->stringToProxy(((m_pConf->MASTER_PROXY_INFO).c_str()));
m_pServicePrx = ChunkServerServicePrx::checkedCast(base);
}
}catch(const Ice::Exception &ex){
cout<<"ice enroll failed"<<endl;
return -1;
}
init = 1;
Address addr;
addr.name=m_pConf->LOCALE_IP;
addr.port=m_pConf->DATA_SOCKET_PORT;
m_pServicePrx->enroll(addr);
return 1;
}
示例8: main
int main(int argc, char *argv[]) {
int status = 0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectPrx base
= ic->stringToProxy(
"SimplePrinter:default -p 10000");
PrinterPrx printer = PrinterPrx::checkedCast(base);
if (!printer)
throw "Invalid proxy";
printer->printString("Hello world from hupantingxue!");
} catch (const Ice::Exception &e) {
cerr << e << endl;
status = 1;
} catch (const char *msg) {
cerr << msg << endl;
status = 1;
}
if (ic) {
ic->destroy();
}
return status;
}
示例9: LoadConfigurationError
Client::Client() {
try {
// We use ip address and process id to identify a client.
char hostname[100];
gethostname(hostname, 100);
m_address.name = hostname;
m_address.port = getpid();
// Get configuration.
string homedir = getenv("HOME");
if (!m_configured && !setFromFile("tfs_client.ini")
&& !setFromFile(homedir + "/.tfs_client.ini")
&& !setFromFile("/etc/tfs_client.ini")) {
//LOG_FATAL("Client: Throw api::LoadConfigurationError")
throw api::LoadConfigurationError();
}
// Initialize client logger.
if (m_conf.logFile[0] == '~')
m_conf.logFile = homedir + m_conf.logFile.substr(1);
helpers::LogLog::getLogLog()->setInternalDebugging(false);
SharedAppenderPtr append_1(
new RollingFileAppender(m_conf.logFile, 1024 * 1024, 1));
std::string pattern = "%D %p - %m\n";
append_1->setLayout(std::auto_ptr<Layout>(new PatternLayout(pattern)));
Logger logger = Logger::getInstance("tfs_client");
logger.addAppender(append_1);
// Set logger level
if (m_conf.logLevel == "FATAL") logger.setLogLevel(FATAL_LOG_LEVEL);
if (m_conf.logLevel == "ERROR") logger.setLogLevel(ERROR_LOG_LEVEL);
if (m_conf.logLevel == "WARN") logger.setLogLevel(WARN_LOG_LEVEL);
if (m_conf.logLevel == "INFO") logger.setLogLevel(INFO_LOG_LEVEL);
if (m_conf.logLevel == "DEBUG") logger.setLogLevel(DEBUG_LOG_LEVEL);
LOG_INFO("Client: Starts TFS Client instance.");
LOG_INFO("Client: Get master address: " <<m_conf.masterIP <<":"
<<m_conf.masterPort);
LOG_INFO("Client: Get default buffer size: " <<m_conf.bufferSize);
LOG_INFO("Client: Get log level: " <<m_conf.logLevel);
LOG_INFO("Client: Get log file: " <<m_conf.logFile);
// Initialize ice.
Ice::CommunicatorPtr ic = Ice::initialize();
Ice::ObjectPrx base = ic->stringToProxy(
"ClientService:tcp -h " + m_conf.masterIP + " -p " + m_conf.masterPort);
m_service = slice::ClientServicePrx::checkedCast(base);
LOG_INFO("Client: Ice service initialized.")
// Begin heartbeat.
IceUtil::ThreadPtr deamon = new HeartbeatDeamon(m_address,
m_service);
deamon->start();
LOG_INFO("Client: Heartbeat Deamon started.")
} catch (Ice::Exception &ex) {
LOG_FATAL("Client: Get Ice Exception:" <<ex.ice_name());
LOG_FATAL("Client: Throw api::ConnectionError");
throw api::ConnectionError();
}
}
示例10: main
int main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
if (argc != 4) {
cerr << "Usage: " << argv[0] << " servername NameService-host local-port\n";
goto clean_up;
}
// Look up the name service.
ostringstream ns_formatter;
ns_formatter << "NameService:tcp -h " << argv[2] << " -p 9010";
Ice::ObjectPrx base =
ic->stringToProxy(ns_formatter.str().c_str());
NameServicePrx ns = NameServicePrx::checkedCast(base);
if (!ns)
throw "Invalid NameService";
// Create local chat display object and support infrastructure.
ostringstream server_formatter;
server_formatter << "tcp -p " << argv[3];
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
"ChatterAdapter", server_formatter.str().c_str());
Ice::ObjectPtr object = new RoomManager_impl(adapter);
Ice::ObjectPrx server =
adapter->add(object, ic->stringToIdentity("RoomManager"));
adapter->activate();
// Register object.
// ns->registerName(argv[1], server);
ic->waitForShutdown();
}
catch (const Ice::Exception& e) {
cerr << e << endl;
status = 1;
}
catch (const char* msg) {
cerr << msg << endl;
status = 1;
}
clean_up:
// We must call ic->destroy() even if an exception is throw above.
if (ic) {
try {
ic->destroy();
}
catch (const Ice::Exception& e) {
cerr << e << endl;
status = 1;
}
}
return status;
}
示例11: sync
void
NodeSessionManager::create(const NodeIPtr& node)
{
{
Lock sync(*this);
assert(!_node);
const_cast<NodeIPtr&>(_node) = node;
Ice::CommunicatorPtr communicator = _node->getCommunicator();
assert(communicator->getDefaultLocator());
Ice::Identity id = communicator->getDefaultLocator()->ice_getIdentity();
//
// Initialize the IceGrid::Query objects. The IceGrid::Query
// interface is used to lookup the registry proxy in case it
// becomes unavailable. Since replicas might not always have
// an up to date registry proxy, we need to query all the
// replicas.
//
Ice::EndpointSeq endpoints = communicator->getDefaultLocator()->ice_getEndpoints();
id.name = "Query";
QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
Ice::EndpointSeq singleEndpoint;
singleEndpoint.push_back(*p);
_queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
}
id.name = "InternalRegistry-Master";
_master = InternalRegistryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));
_thread = new Thread(*this);
_thread->start();
}
//
// Try to create the session. It's important that we wait for the
// creation of the session as this will also try to create sessions
// with replicas (see createdSession below) and this must be done
// before the node is activated.
//
_thread->tryCreateSession(true, IceUtil::Time::seconds(3));
}
示例12: if
RemoteConfig::RemoteConfig(const std::string& name, int argc, char** argv, const Ice::CommunicatorPtr& communicator) :
_status(1)
{
//
// If ControllerHost is defined, we are using a server on a remote host. We expect a
// test controller will already be active. We let exceptions propagate out to
// the caller.
//
// Also look for a ConfigName property, which specifies the name of the configuration
// we are currently testing.
//
std::string controllerHost;
std::string configName;
for(int i = 1; i < argc; ++i)
{
std::string opt = argv[i];
if(opt.find("--ControllerHost") == 0)
{
std::string::size_type pos = opt.find('=');
if(pos != std::string::npos && opt.size() > pos + 1)
{
controllerHost = opt.substr(pos + 1);
}
}
else if(opt.find("--ConfigName") == 0)
{
std::string::size_type pos = opt.find('=');
if(pos != std::string::npos && opt.size() > pos + 1)
{
configName = opt.substr(pos + 1);
}
}
}
Test::Common::ServerPrxPtr server;
if(!controllerHost.empty())
{
std::string prot = communicator->getProperties()->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
std::string host;
if(prot != "bt")
{
host = communicator->getProperties()->getProperty("Ice.Default.Host");
}
Test::Common::StringSeq options;
Test::Common::ControllerPrxPtr controller = ICE_CHECKED_CAST(Test::Common::ControllerPrx,
communicator->stringToProxy("controller:tcp -h " + controllerHost + " -p 15000"));
server = controller->runServer("cpp", name, prot, host, false, configName, options);
server->waitForServer();
}
_server = server;
}
示例13: allTests
int
run(int, char**, const Ice::CommunicatorPtr& comm)
{
void allTests(const Ice::CommunicatorPtr&);
allTests(comm);
//
// Shutdown the IceBox server.
//
ICE_UNCHECKED_CAST(Ice::ProcessPrx, comm->stringToProxy("DemoIceBox/admin -f Process:default -p 9996"))->shutdown();
return EXIT_SUCCESS;
}
示例14:
void
ServerManagerI::startServer(const Ice::Current&)
{
for(::std::vector<Ice::CommunicatorPtr>::const_iterator i = _communicators.begin(); i != _communicators.end(); ++i)
{
(*i)->waitForShutdown();
(*i)->destroy();
}
_communicators.clear();
//
// Simulate a server: create a new communicator and object
// adapter. The object adapter is started on a system allocated
// port. The configuration used here contains the Ice.Locator
// configuration variable. The new object adapter will register
// its endpoints with the locator and create references containing
// the adapter id instead of the endpoints.
//
Ice::CommunicatorPtr serverCommunicator = Ice::initialize(_initData);
_communicators.push_back(serverCommunicator);
//
// Use fixed port to ensure that OA re-activation doesn't re-use previous port from
// another OA (e.g.: TestAdapter2 is re-activated using port of TestAdapter).
//
{
std::ostringstream os;
os << "default -p " << _nextPort++;
serverCommunicator->getProperties()->setProperty("TestAdapter.Endpoints", os.str());
}
{
std::ostringstream os;
os << "default -p " << _nextPort++;
serverCommunicator->getProperties()->setProperty("TestAdapter2.Endpoints", os.str());
}
Ice::ObjectAdapterPtr adapter = serverCommunicator->createObjectAdapter("TestAdapter");
Ice::ObjectAdapterPtr adapter2 = serverCommunicator->createObjectAdapter("TestAdapter2");
Ice::ObjectPrxPtr locator = serverCommunicator->stringToProxy("locator:default -p 12010");
adapter->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
adapter2->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
Ice::ObjectPtr object = ICE_MAKE_SHARED(TestI, adapter, adapter2, _registry);
_registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test")));
_registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test2")));
adapter->add(object, serverCommunicator->stringToIdentity("test3"));
adapter->activate();
adapter2->activate();
}
示例15: main
int main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectPrx base = ic->stringToProxy("asii2_adapter:default -p 10800");
CineTicketServicePrx remoteService = CineTicketServicePrx::checkedCast(base);
if (!remoteService)throw "Invalid proxy";
int horaSesion;
struct consultasesion conActual;
int i;
while(1){
horaSesion=0;
cout<<"Introduzca la hora de la sesión a consultar: (22 o 01)"<< endl;
while(!(horaSesion==22 || horaSesion==01)){
cin >> horaSesion;
}
conActual = remoteService->consulta(horaSesion);
cout<<"Hora sesión:"<< horaSesion<< endl;
cout<<"Estado de la sala:"<< endl;
for (i=0; i<10; i++){
cout<<"["<< i+1 << "]" << conActual.s[i] << endl;
}
}
} catch (const Ice::Exception& ex) {
cerr << ex << endl;
status = 1;
} catch (const char* msg) {
cerr << msg << endl;
status = 1;
}
if (ic)
ic->destroy();
return status;
}