本文整理汇总了C++中icestorm::TopicManagerPrx::create方法的典型用法代码示例。如果您正苦于以下问题:C++ TopicManagerPrx::create方法的具体用法?C++ TopicManagerPrx::create怎么用?C++ TopicManagerPrx::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类icestorm::TopicManagerPrx
的用法示例。
在下文中一共展示了TopicManagerPrx::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
ObserverTopic::ObserverTopic(const IceStorm::TopicManagerPrx& topicManager, const string& name, Ice::Long dbSerial) :
_logger(topicManager->ice_getCommunicator()->getLogger()), _serial(0), _dbSerial(dbSerial)
{
for(int i = 0; i < static_cast<int>(sizeof(encodings) / sizeof(Ice::EncodingVersion)); ++i)
{
ostringstream os;
os << name << "-" << Ice::encodingVersionToString(encodings[i]);
IceStorm::TopicPrx t;
try
{
t = topicManager->create(os.str());
}
catch(const IceStorm::TopicExists&)
{
t = topicManager->retrieve(os.str());
}
//
// NOTE: collocation optimization needs to be turned on for the
// topic because the subscribe() method is given a fixed proxy
// which can't be marshalled.
//
_topics[encodings[i]] = t->ice_collocationOptimized(true);
_basePublishers.push_back(
t->getPublisher()->ice_collocationOptimized(false)->ice_encodingVersion(encodings[i]));
}
}
示例2: exit
serverI::serverI(char* ipToSet, char *portToSet){
port = portToSet;
ip = ipToSet;
ic = Ice::initialize();
cout<<"----- Initialisation des fichiers audio :";
if(initFiles())
cout<<" OK"<<endl;
else{
cerr << " Erreur" << endl;
exit(1);
}
cout<<"----- Initialisation du Topic :";
// PREPARE TOPIC FOR PUBLISHING
string topicName = "serv";
Ice::ObjectPrx obj = ic->stringToProxy("server/TopicManager:tcp -h "+ip+" -p 10000");
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(obj);
if(!manager)
{
exit(1);
}
IceStorm::TopicPrx topic;
try
{
cout<<"OK"<<endl;
topic = manager->retrieve(topicName);
}
catch(const IceStorm::NoSuchTopic&)
{
try
{
cout<<"OK"<<endl;
topic = manager->create(topicName);
}
catch(const IceStorm::TopicExists&)
{
cout<<"Error"<<endl;
exit(1);
}
}
Ice::ObjectPrx publisher = topic->getPublisher();
publisher = publisher->ice_oneway();
serv = MonitorPrx::uncheckedCast(publisher);
cout<<"----- Lancement du serveur "<<endl;
initStreaming();
}
示例3: Startup
bool Publisher::Startup(void)
{
this->IceInitialize();
IceStorm::TopicManagerPrx manager;
try {
manager = IceStorm::TopicManagerPrx::checkedCast(this->IceCommunicator->propertyToProxy("TopicManager.Proxy"));
} catch (const Ice::ConnectionRefusedException & e) {
SCLOG_ERROR << PUBLISHER_INFO << "Failed to initialize IceStorm. Check if IceBox is running: " << e.what() << std::endl;
return false;
}
if (!manager) {
SCLOG_ERROR << PUBLISHER_INFO << "Invalid proxy" << std::endl;
return false;
}
// Retrieve the topic.
IceStorm::TopicPrx topic;
try {
topic = manager->retrieve(this->TopicName);
} catch(const IceStorm::NoSuchTopic&) {
try {
topic = manager->create(this->TopicName);
}
catch(const IceStorm::TopicExists&) {
SCLOG_ERROR << PUBLISHER_INFO << "Topic not found. Try again." << std::endl;
return false;
}
}
// Get the topic's publisher object, and create topic proxy
Ice::ObjectPrx publisher = topic->getPublisher();
// Get the topic's publisher object, and create a proper proxy depending on
// the topic.
switch (this->Topic) {
case Topic::CONTROL:
PublisherControl = ControlPrx::uncheckedCast(publisher);
break;
case Topic::DATA:
PublisherData = DataPrx::uncheckedCast(publisher);
break;
default:
SCASSERT(false);
}
//BaseType::Startup();
return true;
}
示例4: appName
int
Server::run(int argc, char*[])
{
if(argc > 1)
{
cerr << appName() << ": too many arguments" << endl;
return EXIT_FAILURE;
}
Ice::PropertiesPtr properties = communicator()->getProperties();
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(
communicator()->propertyToProxy("TopicManager.Proxy"));
if(!manager)
{
cerr << appName() << ": invalid proxy" << endl;
return EXIT_FAILURE;
}
IceStorm::TopicPrx topic;
try
{
topic = manager->retrieve("counter");
}
catch(const IceStorm::NoSuchTopic&)
{
try
{
topic = manager->create("counter");
}
catch(const IceStorm::TopicExists&)
{
cerr << appName() << ": topic exists, please try again." << endl;
return EXIT_FAILURE;
}
}
//
// Create the servant to receive the events.
//
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Counter");
Demo::CounterPtr counter = new CounterI(topic);
adapter->add(counter, communicator()->stringToIdentity("counter"));
adapter->activate();
communicator()->waitForShutdown();
return EXIT_SUCCESS;
}
示例5: catch
ReplicaCache::ReplicaCache(const Ice::CommunicatorPtr& communicator, const IceStorm::TopicManagerPrx& topicManager) :
_communicator(communicator)
{
IceStorm::TopicPrx t;
try
{
t = topicManager->create("ReplicaObserverTopic");
}
catch(const IceStorm::TopicExists&)
{
t = topicManager->retrieve("ReplicaObserverTopic");
}
const_cast<IceStorm::TopicPrx&>(_topic) = IceStorm::TopicPrx::uncheckedCast(t->ice_collocationOptimized(true));
const_cast<ReplicaObserverPrx&>(_observers) = ReplicaObserverPrx::uncheckedCast(_topic->getPublisher());
}
示例6: 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();
}
示例7: run
int inversekinematicsAgentComp::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
QApplication a(argc, argv); // GUI application
#else
QCoreApplication a(argc, argv); // NON-GUI application
#endif
int status=EXIT_SUCCESS;
// Remote server proxy access example
// RemoteComponentPrx remotecomponent_proxy;
BodyInverseKinematicsPrx bodyinversekinematics_proxy;
AGMAgentTopicPrx agmagenttopic_proxy;
string proxy;
// User variables
initialize();
// Remote server proxy creation example
// try
// {
// // Load the remote server proxy
// proxy = getProxyString("RemoteProxy");
// remotecomponent_proxy = RemotePrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
// if( !remotecomponent_proxy )
// {
// rInfo(QString("Error loading proxy!"));
// return EXIT_FAILURE;
// }
//catch(const Ice::Exception& ex)
//{
// cout << "[" << PROGRAM_NAME << "]: Exception: " << ex << endl;
// return EXIT_FAILURE;
//}
//rInfo("RemoteProxy initialized Ok!");
// // Now you can use remote server proxy (remotecomponent_proxy) as local object
//Remote server proxy creation example
try
{
bodyinversekinematics_proxy = BodyInverseKinematicsPrx::uncheckedCast( communicator()->stringToProxy( getProxyString("BodyInverseKinematicsProxy") ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("BodyInverseKinematicsProxy initialized Ok!");
mprx["BodyInverseKinematicsProxy"] = (::IceProxy::Ice::Object*)(&bodyinversekinematics_proxy);
IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
IceStorm::TopicPrx agmagenttopic_topic;
while(!agmagenttopic_topic){
try {
agmagenttopic_topic = topicManager->retrieve("AGMAgentTopic");
}catch (const IceStorm::NoSuchTopic&){
try{
agmagenttopic_topic = topicManager->create("AGMAgentTopic");
}catch (const IceStorm::TopicExists&){
// Another client created the topic.
}
}
}
Ice::ObjectPrx agmagenttopic_pub = agmagenttopic_topic->getPublisher()->ice_oneway();
AGMAgentTopicPrx agmagenttopic = AGMAgentTopicPrx::uncheckedCast(agmagenttopic_pub);
mprx["AGMAgentTopicPub"] = (::IceProxy::Ice::Object*)(&agmagenttopic);
GenericWorker *worker = new SpecificWorker(mprx);
//Monitor thread
GenericMonitor *monitor = new SpecificMonitor(worker,communicator());
QObject::connect(monitor,SIGNAL(kill()),&a,SLOT(quit()));
QObject::connect(worker,SIGNAL(kill()),&a,SLOT(quit()));
monitor->start();
if ( !monitor->isRunning() )
return status;
try
{
// Server adapter creation and publication
Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapter("CommonBehavior");
CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
adapterCommonBehavior->activate();
// Server adapter creation and publication
Ice::ObjectAdapterPtr AGMExecutiveTopic_adapter = communicator()->createObjectAdapter("AGMExecutiveTopicTopic");
AGMExecutiveTopicPtr agmexecutivetopicI_ = new AGMExecutiveTopicI(worker);
Ice::ObjectPrx agmexecutivetopic_proxy = AGMExecutiveTopic_adapter->addWithUUID(agmexecutivetopicI_)->ice_oneway();
IceStorm::TopicPrx agmexecutivetopic_topic;
while(!agmexecutivetopic_topic){
try {
agmexecutivetopic_topic = topicManager->retrieve("AGMExecutiveTopic");
IceStorm::QoS qos;
agmexecutivetopic_topic->subscribeAndGetPublisher(qos, agmexecutivetopic_proxy);
}
catch (const IceStorm::NoSuchTopic&) {
// Error! No topic found!
//.........这里部分代码省略.........
示例8: IcestormSubscribe
/***********************************************************
subscribe to icestorm
***********************************************************/
void MapHandler::IcestormSubscribe()
{
Ice::ObjectPrx proxy = _adapter->addWithUUID(new InfosReceiverServant(&_SD));
_observer = LbaNet::ActorsObserverPrx::uncheckedCast(proxy);
IceStorm::TopicManagerPrx manager;
try
{
manager = IceStorm::TopicManagerPrx::uncheckedCast(
_communicator->propertyToProxy("TopicManagerProxy"));
}
catch(const IceUtil::Exception& ex)
{
std::cout<<"MapHandler - Exception getting the actor topic manager: "<<ex.what()<<std::endl;
}
catch(...)
{
std::cout<<"MapHandler - Unknown exception getting the actor topic manager. "<<std::endl;
}
try
{
_topic = manager->create(_mapName);
}
catch(const IceStorm::TopicExists&)
{
_topic = manager->retrieve(_mapName);
}
catch(const IceUtil::Exception& ex)
{
std::cout<<"MapHandler - Exception creating actor topic "<<ex.what()<<std::endl;
}
catch(...)
{
std::cout<<"MapHandler - Unknown exception creating actor topic. "<<std::endl;
}
try
{
_topic->subscribeAndGetPublisher(IceStorm::QoS(), _observer);
}
catch(const IceUtil::Exception& ex)
{
std::cout<<"MapHandler - Exception creating actor publisher "<<ex.what()<<std::endl;
}
catch(...)
{
std::cout<<"MapHandler - Unknown exception creating actor publisher. "<<std::endl;
}
Ice::ObjectPrx pub;
try
{
pub = _topic->getPublisher();
_publisher = ActorsObserverPrx::uncheckedCast(pub->ice_oneway());
}
catch(const IceUtil::Exception& ex)
{
std::cout<<"MapHandler - Exception getting the publisher "<<ex.what()<<std::endl;
}
catch(...)
{
std::cout<<"MapHandler - Unknown exception getting the publisher. "<<std::endl;
}
}
示例9: run
int JoystickPublishComp::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
QApplication a(argc, argv); // GUI application
#else
QCoreApplication a(argc, argv); // NON-GUI application
#endif
int status=EXIT_SUCCESS;
// Remote server proxy access example
// RemoteComponentPrx remotecomponent_proxy;
string proxy;
// User variables
initialize();
// Remote server proxy creation example
// try
// {
// // Load the remote server proxy
// proxy = getProxyString("RemoteProxy");
// remotecomponent_proxy = RemotePrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
// if( !remotecomponent_proxy )
// {
// rInfo(QString("Error loading proxy!"));
// return EXIT_FAILURE;
// }
//catch(const Ice::Exception& ex)
//{
// cout << "[" << PROGRAM_NAME << "]: Exception: " << ex << endl;
// return EXIT_FAILURE;
//}
//rInfo("RemoteProxy initialized Ok!");
// // Now you can use remote server proxy (remotecomponent_proxy) as local object
IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
IceStorm::TopicPrx joystickadapter_topic;
while(!joystickadapter_topic){
try {
joystickadapter_topic = topicManager->create("JoystickAdapter"); // communicator()->getProperties()->getProperty("JoystickAdapter") does not work!
}catch (const IceStorm::TopicExists&){
// Another client created the topic.
try{
joystickadapter_topic = topicManager->retrieve("JoystickAdapter"); // communicator()->getProperties()->getProperty("JoystickAdapter") does not work!
}catch (const IceStorm::NoSuchTopic&){
//Error. Topic does not exist.
}
}
}
Ice::ObjectPrx joystickadapter_pub = joystickadapter_topic->getPublisher()->ice_oneway();
JoystickAdapterPrx joystickadapter = JoystickAdapterPrx::uncheckedCast(joystickadapter_pub);
mprx["JoystickAdapterPub"] = (::IceProxy::Ice::Object*)(&joystickadapter);
GenericWorker *worker = new SpecificWorker(mprx);
//Monitor thread
GenericMonitor *monitor = new SpecificMonitor(worker,communicator());
QObject::connect(monitor,SIGNAL(kill()),&a,SLOT(quit()));
QObject::connect(worker,SIGNAL(kill()),&a,SLOT(quit()));
monitor->start();
if ( !monitor->isRunning() )
return status;
try
{
// Server adapter creation and publication
Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapter("CommonBehavior");
CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
adapterCommonBehavior->activate();
// Server adapter creation and publication
cout << SERVER_FULL_NAME " started" << endl;
// User defined QtGui elements ( main window, dialogs, etc )
#ifdef USE_QTGUI
//ignoreInterrupt(); // Uncomment if you want the component to ignore console SIGINT signal (ctrl+c).
a.setQuitOnLastWindowClosed( true );
#endif
// Run QT Application Event Loop
a.exec();
status = EXIT_SUCCESS;
}
catch(const Ice::Exception& ex)
{
status = EXIT_FAILURE;
cout << "[" << PROGRAM_NAME << "]: Exception raised on main thread: " << endl;
cout << ex;
#ifdef USE_QTGUI
a.quit();
#endif
monitor->exit(0);
}
//.........这里部分代码省略.........
示例10: a
int ::mycomp::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
QApplication a(argc, argv); // GUI application
#else
QCoreApplication a(argc, argv); // NON-GUI application
#endif
int status=EXIT_SUCCESS;
ControllerPrx controller_proxy;
DifferentialRobotPrx differentialrobot_proxy;
LaserPrx laser_proxy;
string proxy, tmp;
initialize();
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "ControllerProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy ControllerProxy\n";
}
controller_proxy = ControllerPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("ControllerProxy initialized Ok!");
mprx["ControllerProxy"] = (::IceProxy::Ice::Object*)(&controller_proxy);//Remote server proxy creation example
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "DifferentialRobotProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy DifferentialRobotProxy\n";
}
differentialrobot_proxy = DifferentialRobotPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("DifferentialRobotProxy initialized Ok!");
mprx["DifferentialRobotProxy"] = (::IceProxy::Ice::Object*)(&differentialrobot_proxy);//Remote server proxy creation example
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "LaserProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy LaserProxy\n";
}
laser_proxy = LaserPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("LaserProxy initialized Ok!");
mprx["LaserProxy"] = (::IceProxy::Ice::Object*)(&laser_proxy);//Remote server proxy creation example
IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
SpecificWorker *worker = new SpecificWorker(mprx);
//Monitor thread
SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
monitor->start();
if ( !monitor->isRunning() )
return status;
while (!monitor->ready)
{
usleep(10000);
}
try
{
// Server adapter creation and publication
if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
}
Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
adapterCommonBehavior->activate();
//.........这里部分代码省略.........
示例11: a
int ::dialogagent::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
QApplication a(argc, argv); // GUI application
#else
QCoreApplication a(argc, argv); // NON-GUI application
#endif
sigset_t sigs;
sigemptyset(&sigs);
sigaddset(&sigs, SIGHUP);
sigaddset(&sigs, SIGINT);
sigaddset(&sigs, SIGTERM);
sigprocmask(SIG_UNBLOCK, &sigs, 0);
int status=EXIT_SUCCESS;
SpeechPrx speech_proxy;
AGMExecutivePrx agmexecutive_proxy;
string proxy, tmp;
initialize();
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "SpeechProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy SpeechProxy\n";
}
speech_proxy = SpeechPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("SpeechProxy initialized Ok!");
mprx["SpeechProxy"] = (::IceProxy::Ice::Object*)(&speech_proxy);//Remote server proxy creation example
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "AGMExecutiveProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy AGMExecutiveProxy\n";
}
agmexecutive_proxy = AGMExecutivePrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("AGMExecutiveProxy initialized Ok!");
mprx["AGMExecutiveProxy"] = (::IceProxy::Ice::Object*)(&agmexecutive_proxy);//Remote server proxy creation example
IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
SpecificWorker *worker = new SpecificWorker(mprx);
//Monitor thread
SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
monitor->start();
if ( !monitor->isRunning() )
return status;
while (!monitor->ready)
{
usleep(10000);
}
try
{
// Server adapter creation and publication
if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
}
Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
adapterCommonBehavior->activate();
// Server adapter creation and publication
if (not GenericMonitor::configGetString(communicator(), prefix, "AGMCommonBehavior.Endpoints", tmp, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy AGMCommonBehavior";
}
Ice::ObjectAdapterPtr adapterAGMCommonBehavior = communicator()->createObjectAdapterWithEndpoints("AGMCommonBehavior", tmp);
AGMCommonBehaviorI *agmcommonbehavior = new AGMCommonBehaviorI(worker);
//.........这里部分代码省略.........
示例12: a
int ::speech::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
QApplication a(argc, argv); // GUI application
#else
QCoreApplication a(argc, argv); // NON-GUI application
#endif
int status=EXIT_SUCCESS;
SpeechInformPrx speechinform_proxy;
string proxy, tmp;
initialize();
IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
IceStorm::TopicPrx speechinform_topic;
while (!speechinform_topic)
{
try
{
speechinform_topic = topicManager->retrieve("SpeechInform");
}
catch (const IceStorm::NoSuchTopic&)
{
try
{
speechinform_topic = topicManager->create("SpeechInform");
}
catch (const IceStorm::TopicExists&) {
// Another client created the topic.
}
}
}
Ice::ObjectPrx speechinform_pub = speechinform_topic->getPublisher()->ice_oneway();
SpeechInformPrx speechinform = SpeechInformPrx::uncheckedCast(speechinform_pub);
mprx["SpeechInformPub"] = (::IceProxy::Ice::Object*)(&speechinform);
SpecificWorker *worker = new SpecificWorker(mprx);
//Monitor thread
SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
monitor->start();
if ( !monitor->isRunning() )
return status;
while (!monitor->ready)
{
usleep(10000);
}
try
{
// Server adapter creation and publication
if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
}
Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
adapterCommonBehavior->activate();
// Server adapter creation and publication
if (not GenericMonitor::configGetString(communicator(), prefix, "SpeechSIMDTopic.Endpoints", tmp, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy SpeechSIMDProxy";
}
Ice::ObjectAdapterPtr SpeechSIMD_adapter = communicator()->createObjectAdapterWithEndpoints("speechsimd", tmp);
SpeechSIMDPtr speechsimdI_ = new SpeechSIMDI(worker);
Ice::ObjectPrx speechsimd = SpeechSIMD_adapter->addWithUUID(speechsimdI_)->ice_oneway();
IceStorm::TopicPrx speechsimd_topic;
if(!speechsimd_topic) {
try {
speechsimd_topic = topicManager->create("SpeechSIMD");
}
catch (const IceStorm::TopicExists&) {
//Another client created the topic
try {
speechsimd_topic = topicManager->retrieve("SpeechSIMD");
}
catch(const IceStorm::NoSuchTopic&)
{
//Error. Topic does not exist
}
}
IceStorm::QoS qos;
speechsimd_topic->subscribeAndGetPublisher(qos, speechsimd);
}
SpeechSIMD_adapter->activate();
//.........这里部分代码省略.........
示例13: a
int ::AprilTagsComp::run(int argc, char* argv[])
{
QCoreApplication a(argc, argv); // NON-GUI application
sigset_t sigs;
sigemptyset(&sigs);
sigaddset(&sigs, SIGHUP);
sigaddset(&sigs, SIGINT);
sigaddset(&sigs, SIGTERM);
sigprocmask(SIG_UNBLOCK, &sigs, 0);
int status=EXIT_SUCCESS;
RGBDPrx rgbd_proxy;
RGBDBusPrx rgbdbus_proxy;
AprilTagsPrx apriltags_proxy;
CameraPrx camera_proxy;
string proxy, tmp;
initialize();
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "RGBDProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy RGBDProxy\n";
}
rgbd_proxy = RGBDPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("RGBDProxy initialized Ok!");
mprx["RGBDProxy"] = (::IceProxy::Ice::Object*)(&rgbd_proxy);//Remote server proxy creation example
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "RGBDBusProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy RGBDBusProxy\n";
}
rgbdbus_proxy = RGBDBusPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("RGBDBusProxy initialized Ok!");
mprx["RGBDBusProxy"] = (::IceProxy::Ice::Object*)(&rgbdbus_proxy);//Remote server proxy creation example
try
{
if (not GenericMonitor::configGetString(communicator(), prefix, "CameraProxy", proxy, ""))
{
cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CameraProxy\n";
}
camera_proxy = CameraPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
}
catch(const Ice::Exception& ex)
{
cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
return EXIT_FAILURE;
}
rInfo("CameraProxy initialized Ok!");
mprx["CameraProxy"] = (::IceProxy::Ice::Object*)(&camera_proxy);//Remote server proxy creation example
IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
IceStorm::TopicPrx apriltags_topic;
while (!apriltags_topic)
{
try
{
apriltags_topic = topicManager->retrieve("AprilTags");
}
catch (const IceStorm::NoSuchTopic&)
{
try
{
apriltags_topic = topicManager->create("AprilTags");
}
catch (const IceStorm::TopicExists&){
// Another client created the topic.
}
}
}
Ice::ObjectPrx apriltags_pub = apriltags_topic->getPublisher()->ice_oneway();
AprilTagsPrx apriltags = AprilTagsPrx::uncheckedCast(apriltags_pub);
mprx["AprilTagsPub"] = (::IceProxy::Ice::Object*)(&apriltags);
//.........这里部分代码省略.........
示例14: if
//.........这里部分代码省略.........
{
option = Twoway;
}
else if(option != Twoway && option != Ordered)
{
cerr << argv[0] << ": retryCount requires a twoway proxy" << endl;
return EXIT_FAILURE;
}
}
if(batch && (option == Twoway || option == Ordered))
{
cerr << argv[0] << ": batch can only be set with oneway or datagram" << endl;
return EXIT_FAILURE;
}
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(
communicator()->propertyToProxy("TopicManager.Proxy"));
if(!manager)
{
cerr << appName() << ": invalid proxy" << endl;
return EXIT_FAILURE;
}
IceStorm::TopicPrx topic;
try
{
topic = manager->retrieve(topicName);
}
catch(const IceStorm::NoSuchTopic&)
{
try
{
topic = manager->create(topicName);
}
catch(const IceStorm::TopicExists&)
{
cerr << appName() << ": temporary failure. try again." << endl;
return EXIT_FAILURE;
}
}
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Clock.Subscriber");
//
// Add a servant for the Ice object. If --id is used the identity
// comes from the command line, otherwise a UUID is used.
//
// id is not directly altered since it is used below to detect
// whether subscribeAndGetPublisher can raise AlreadySubscribed.
//
Ice::Identity subId;
subId.name = id;
if(subId.name.empty())
{
subId.name = IceUtil::generateUUID();
}
Ice::ObjectPrx subscriber = adapter->add(new ClockI, subId);
//
// Activate the object adapter before subscribing.
//
adapter->activate();
IceStorm::QoS qos;
if(!retryCount.empty())
示例15: main
void main()
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
initData.properties->setProperty("Ice.MessageSizeMax", "102400" );//默认是1024,单位KB
initData.properties->setProperty("Ice.ThreadPool.Server.Size", "1");
initData.properties->setProperty("Ice.ThreadPool.Server.SizeMax", "1000" );
initData.properties->setProperty("Ice.ThreadPool.Server.SizeWarn", "1024");
Ice::CommunicatorPtr communicatorPtr = Ice::initialize(initData);
char szStormHost[100]={0};
char szStromPort[10]={0};
char szDir[MAX_PATH] = {0};
GetModuleFileName(NULL,szDir,MAX_PATH);
string strIniFile = szDir;
strIniFile = strIniFile.substr(0,strIniFile.length()-3) + "ini";
GetPrivateProfileString("NewsPub","StormHost","localhost",szStormHost,100,strIniFile.c_str());
WritePrivateProfileString("NewsPub","StormHost",szStormHost,strIniFile.c_str());
GetPrivateProfileString("NewsPub","StromPort","10000",szStromPort,100,strIniFile.c_str());
WritePrivateProfileString("NewsPub","StromPort",szStromPort,strIniFile.c_str());
char szStr[1000]={0};
sprintf_s(szStr,"StormNewsDemo/TopicManager:tcp -h %s -p %s",szStormHost,szStromPort);
// icestorm的地址"StormNewsDemo/TopicManager:tcp -h xiangzhenwei.peraportal.com -p 10000"
IceStorm::TopicManagerPrx manager = NULL;
try
{
manager = IceStorm::TopicManagerPrx::checkedCast(communicatorPtr->stringToProxy(szStr));
}
catch (const Ice::Exception &e)
{
cerr << e.what();
return;
}
if(!manager)
{
cerr << "NewsSub.exe" << ": invalid proxy" << endl;
return;
}
IceStorm::TopicPrx topic;
try
{
topic = manager->retrieve("news");
}
catch(const IceStorm::NoSuchTopic&)
{
try
{
topic = manager->create("news");
}
catch(const IceStorm::TopicExists&)
{
cerr << "NewsSub.exe" << ": temporary failure. try again." << endl;
return;
}
}
// 接收端监听消息的地址"tcp -h 0.0.0.0:udp -h 0.0.0.0"
string strEndPoint = "tcp -h 0.0.0.0:udp -h 0.0.0.0";
Ice::ObjectAdapterPtr adapter = communicatorPtr->createObjectAdapterWithEndpoints("News.Subscriber", strEndPoint );
//
// Add a servant for the Ice object. If --id is used the identity
// comes from the command line, otherwise a UUID is used.
//
// id is not directly altered since it is used below to detect
// whether subscribeAndGetPublisher can raise AlreadySubscribed.
//
Ice::Identity subId;
subId.name = IceUtil::generateUUID();
Ice::ObjectPrx subscriber = adapter->add(new NewsI, subId);
g_strClientId = subId.name;
Ice::CommunicatorPtr communicatorPtr2 = InitCommunicator();
char szEndPoints[1000]={0};
sprintf_s(szEndPoints,"Pera601DemoServerService:tcp -h %s -p %s -t 5000", szStormHost, "20131");
try
{
PcIdToWsServerPrx m_pPrx = PcIdToWsServerPrx::checkedCast(communicatorPtr2->stringToProxy(szEndPoints));
m_pPrx = m_pPrx->ice_twoway()->ice_timeout(20000)->ice_secure(false);
m_pPrx->TellClientId(subId.name);
}
catch(const Ice::Exception& ex)
{
printf("远程调用服务端失败,ICE异常:%s", ex.ice_name().c_str());
return;
}
//
// Activate the object adapter before subscribing.
//
adapter->activate();
subscriber = subscriber->ice_oneway();
IceStorm::QoS qos;
//.........这里部分代码省略.........