本文整理汇总了C++中ice::CommunicatorHolder类的典型用法代码示例。如果您正苦于以下问题:C++ CommunicatorHolder类的具体用法?C++ CommunicatorHolder怎么用?C++ CommunicatorHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommunicatorHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
int
main(int argc, char* argv[])
{
try {
// Create Ice communicator
//
Ice::CommunicatorHolder icHolder = Ice::initialize(argc, argv);
// Create a proxy for the root directory
//
auto base = icHolder->stringToProxy("RootDir:default -p 10000");
if (!base)
throw std::runtime_error("Could not create proxy");
// Down-cast the proxy to a Directory proxy
//
auto rootDir = Ice::checkedCast<DirectoryPrx>(base);
if (!rootDir)
throw std::runtime_error("Invalid proxy");
// Recursively list the contents of the root directory
//
cout << "Contents of root directory:" << endl;
listRecursive(rootDir);
} catch(const std::exception& e) {
cerr << e.what() << endl;
return 1;
}
return 0;
}
示例2: run
int
main(int argc, char* argv[])
{
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
#endif
try
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
//
// Its possible to have batch oneway requests dispatched after
// the adapter is deactivated due to thread scheduling so we
// supress this warning.
//
initData.properties->setProperty("Ice.Warn.Dispatch", "0");
Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
return run(argc, argv, ich.communicator());
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
return EXIT_FAILURE;
}
}
示例3: rc
int
main(int argc, char* argv[])
{
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
# if defined(__linux)
Ice::registerIceBT();
# endif
#endif
try
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
initData.properties->setProperty("Ice.Warn.Connections", "0");
initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max
Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
RemoteConfig rc("Ice/exceptions", argc, argv, ich.communicator());
int status = run(argc, argv, ich.communicator());
rc.finished(status);
return status;
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
return EXIT_FAILURE;
}
}
示例4: initialize
void
Server::run(int argc, char** argv)
{
#ifdef ICE_STATIC_LIBS
Ice::registerIceDiscovery();
#endif
Ice::CommunicatorHolder communicator = initialize(argc, argv);
Ice::PropertiesPtr properties = communicator->getProperties();
int num = argc == 2 ? atoi(argv[1]) : 0;
properties->setProperty("ControlAdapter.Endpoints", getTestEndpoint(num));
{
ostringstream os;
os << "control" << num;
properties->setProperty("ControlAdapter.AdapterId", os.str());
}
properties->setProperty("ControlAdapter.ThreadPool.Size", "1");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("ControlAdapter");
{
ostringstream os;
os << "controller" << num;
adapter->add(ICE_MAKE_SHARED(ControllerI), Ice::stringToIdentity(os.str()));
}
adapter->activate();
serverReady();
communicator->waitForShutdown();
}
示例5: run
int
main(int argc, char* argv[])
{
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
#endif
try
{
//
// In this test, we need a longer server idle time, otherwise
// our test servers may time out before they are used in the
// test.
//
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
initData.properties->setProperty("Ice.ServerIdleTime", "120"); // Two minutes.
Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
return run(argc, argv, ich.communicator());
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
return EXIT_FAILURE;
}
}
示例6: run
int
main(int argc, char* argv[])
{
try
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
//
// This test kills connections, so we don't want warnings.
//
initData.properties->setProperty("Ice.Warn.Connections", "0");
initData.properties->setProperty("Ice.MessageSizeMax", "50000");
// This test relies on filling the TCP send/recv buffer, so
// we rely on a fixed value for these buffers.
initData.properties->setProperty("Ice.TCP.RcvSize", "50000");
//
// Setup the test transport plug-in.
//
initData.properties->setProperty("Ice.Plugin.Test", "TestTransport:createTestTransport");
string defaultProtocol = initData.properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
initData.properties->setProperty("Ice.Default.Protocol", "test-" + defaultProtocol);
Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
return run(argc, argv, ich.communicator());
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
return EXIT_FAILURE;
}
}
示例7: initialize
void
Server::run(int argc, char** argv)
{
Ice::CommunicatorHolder communicator = initialize(argc, argv);
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->add(ICE_MAKE_SHARED(TestIntfI), Ice::stringToIdentity("test"));
adapter->activate();
serverReady();
communicator->waitForShutdown();
}
示例8: allTests
void
Client::run(int argc, char** argv)
{
Ice::CommunicatorHolder communicator = initialize(argc, argv);
void allTests(Test::TestHelper*);
allTests(this);
//
// Shutdown the IceBox server.
//
ICE_UNCHECKED_CAST(Ice::ProcessPrx,
communicator->stringToProxy("DemoIceBox/admin -f Process:default -p 9996"))->shutdown();
}
示例9: createTestProperties
void
Server::run(int argc, char** argv)
{
#ifdef ICE_STATIC_LIBS
Ice::registerPluginFactory("Test", createTestTransport, false);
#endif
Ice::PropertiesPtr properties = createTestProperties(argc, argv);
//
// This test kills connections, so we don't want warnings.
//
properties->setProperty("Ice.Warn.Connections", "0");
properties->setProperty("Ice.MessageSizeMax", "50000");
//
// This test relies on filling the TCP send/recv buffer, so
// we rely on a fixed value for these buffers.
//
properties->setProperty("Ice.TCP.RcvSize", "50000");
//
// Setup the test transport plug-in.
//
properties->setProperty("Ice.Plugin.Test", "TestTransport:createTestTransport");
string defaultProtocol = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
properties->setProperty("Ice.Default.Protocol", "test-" + defaultProtocol);
Ice::CommunicatorHolder communicator = initialize(argc, argv, properties);
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", getTestEndpoint(1, "tcp"));
communicator->getProperties()->setProperty("ControllerAdapter.ThreadPool.Size", "1");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("ControllerAdapter");
#ifdef ICE_CPP11_MAPPING
shared_ptr<PluginI> plugin = dynamic_pointer_cast<PluginI>(communicator->getPluginManager()->getPlugin("Test"));
#else
PluginI* plugin = dynamic_cast<PluginI*>(communicator->getPluginManager()->getPlugin("Test").get());
#endif
assert(plugin);
ConfigurationPtr configuration = plugin->getConfiguration();
BackgroundControllerIPtr backgroundController = ICE_MAKE_SHARED(BackgroundControllerI, adapter, configuration);
adapter->add(ICE_MAKE_SHARED(BackgroundI, backgroundController), Ice::stringToIdentity("background"));
adapter->add(ICE_MAKE_SHARED(LocatorI, backgroundController), Ice::stringToIdentity("locator"));
adapter->add(ICE_MAKE_SHARED(RouterI, backgroundController), Ice::stringToIdentity("router"));
adapter->activate();
adapter2->add(backgroundController, Ice::stringToIdentity("backgroundController"));
adapter2->activate();
communicator->waitForShutdown();
}
示例10: createTestProperties
void
ServerAMD::run(int argc, char** argv)
{
Ice::PropertiesPtr properties = createTestProperties(argc, argv);
#ifndef ICE_CPP11_MAPPING
properties->setProperty("Ice.CollectObjects", "1");
#endif
Ice::CommunicatorHolder communicator = initialize(argc, argv, properties);
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->add(ICE_MAKE_SHARED(InitialI), Ice::stringToIdentity("initial"));
adapter->activate();
serverReady();
communicator->waitForShutdown();
}
示例11: catch
int
main(int argc, char* argv[])
{
try {
Ice::CommunicatorHolder icHolder = Ice::initialize(argc, argv);
auto adapter = icHolder->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
auto servant = make_shared<PrinterI>();
adapter->add(servant, Ice::stringToIdentity("SimplePrinter"));
adapter->activate();
icHolder->waitForShutdown();
} catch(const std::exception& e) {
cerr << e.what() << endl;
return 1;
}
return 0;
}
示例12: setProcessStringConverter
void
Server::run(int argc, char** argv)
{
setProcessStringConverter(ICE_MAKE_SHARED(Test::StringConverterI));
setProcessWstringConverter(ICE_MAKE_SHARED(Test::WstringConverterI));
Ice::CommunicatorHolder communicator = initialize(argc, argv);
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->add(ICE_MAKE_SHARED(TestIntfI), Ice::stringToIdentity("TEST"));
adapter->add(ICE_MAKE_SHARED(Test1::WstringClassI), Ice::stringToIdentity("WSTRING1"));
adapter->add(ICE_MAKE_SHARED(Test2::WstringClassI), Ice::stringToIdentity("WSTRING2"));
adapter->activate();
serverReady();
communicator->waitForShutdown();
}
示例13: invalid_argument
void
Client::run(int argc, char** argv)
{
Ice::CommunicatorHolder communicator = initialize(argc, argv);
ObjectPrx base = communicator->stringToProxy("Test.IceStorm/TopicManager");
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base);
if(!manager)
{
ostringstream os;
os << argv[0] << ": `Test.IceStorm/TopicManager' is not running";
throw invalid_argument(os.str());
}
ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default:udp");
TopicPrx topic = manager->create("single");
//
// Create subscribers with different QoS.
//
SingleIPtr sub = new SingleI;
topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(sub));
adapter->activate();
// Ensure that getPublisher & getNonReplicatedPublisher work
// correctly.
Ice::ObjectPrx p1 = topic->getPublisher();
Ice::ObjectPrx p2 = topic->getNonReplicatedPublisher();
test(p1->ice_getAdapterId() == "PublishReplicaGroup");
test(p2->ice_getAdapterId() == "Test.IceStorm1.Publish" ||
p2->ice_getAdapterId() == "Test.IceStorm2.Publish" ||
p2->ice_getAdapterId() == "Test.IceStorm3.Publish");
//
// Get a publisher object, create a twoway proxy and then cast to
// a Single object.
//
SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway());
for(int i = 0; i < 1000; ++i)
{
single->event(i);
}
sub->waitForEvents();
}
示例14: run
int
main(int argc, char* argv[])
{
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
#endif
try
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
assert(initData.properties != ich->getProperties());
return run(argc, argv, ich.communicator(), initData);
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
return EXIT_FAILURE;
}
}
示例15: allTests
void
Collocated::run(int argc, char** argv)
{
Ice::CommunicatorHolder communicator = initialize(argc, argv);
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
//
// 2 threads are necessary to dispatch the collocated transient() call with AMI
//
communicator->getProperties()->setProperty("TestAdapter.ThreadPool.Size", "2");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
ServantLocatorPtr locator = ICE_MAKE_SHARED(ServantLocatorI);
adapter->addServantLocator(locator, "");
TestIntfPrxPtr allTests(TestHelper*);
allTests(this);
adapter->waitForDeactivate();
}