本文整理汇总了C++中cosnotifychanneladmin::SupplierAdmin_var::obtain_notification_push_consumer方法的典型用法代码示例。如果您正苦于以下问题:C++ SupplierAdmin_var::obtain_notification_push_consumer方法的具体用法?C++ SupplierAdmin_var::obtain_notification_push_consumer怎么用?C++ SupplierAdmin_var::obtain_notification_push_consumer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cosnotifychanneladmin::SupplierAdmin_var
的用法示例。
在下文中一共展示了SupplierAdmin_var::obtain_notification_push_consumer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
PortableServer::POAManager_var poa_manager;
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(poa_obj.in());
poa_manager = root_poa->the_POAManager();
poa_manager->activate();
/*Get event_channel*/
std::cout << "Create event_channel now" << std::endl;
CosNotifyChannelAdmin::EventChannel_var ec = get_event_channel(orb.in());
//Instanciating the Supplier
CosNotifyComm::StructuredPushSupplier_var sps =
CosNotifyComm::StructuredPushSupplier::_nil();
CosNotifyCommImpl::StructuredPushSupplier *pImpl_sps = new CosNotifyCommImpl::StructuredPushSupplier;
sps = pImpl_sps->_this();
//Obtain a Supplier Admin
CosNotifyChannelAdmin::SupplierAdmin_var sa = ec->default_supplier_admin();
if( sa.in() == CosNotifyChannelAdmin::SupplierAdmin::_nil() ){
std::cerr << "sa is nil!" << std::endl;
return 1;
}
//Obtain a Proxy Consumer
CosNotifyChannelAdmin::ProxyID proxy_id;
CosNotifyChannelAdmin::ClientType ctype = CosNotifyChannelAdmin::STRUCTURED_EVENT;
CosNotifyChannelAdmin::ProxyConsumer_var proxyCon_obj;
try
{
proxyCon_obj = sa->obtain_notification_push_consumer(ctype, proxy_id);
}
catch(CosNotifyChannelAdmin::AdminLimitExceeded err)
{
std::cerr << "CosNotifyChannelAdmin::AdminLimitExceeded Exception!" << std::endl;
throw;
}
CosNotifyChannelAdmin::StructuredProxyPushConsumer_var ppc =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxyCon_obj.in());
//Connecting a Supplier to a Proxy Consumer
try
{
ppc->connect_structured_push_supplier(sps.in());
}
catch (CosEventChannelAdmin::AlreadyConnected ac)
{
std::cerr << "CosEventChannelAdmin::AlreadyConnected" << std::endl;
throw;
}
catch (CORBA::SystemException& se)
{
std::cerr << "System exception occurred during connect: " <<
se << std::endl;
throw;
}
//Demo::demo_send_heart_beat(ppc);
//Send a Demo Notification
CosNotification::StructuredEvent event;
event.header.fixed_header.event_type.domain_name =
CORBA::string_dup("Test_domain");
event.header.fixed_header.event_type.type_name =
CORBA::string_dup("Test_type_name");
event.header.variable_header.length(0);
event.remainder_of_body <<= "";
std::cout << "Sending a demo event...," << std::endl;
std::cout << "event.header.fixed_header.event_type.domain_name = "
<< event.header.fixed_header.event_type.domain_name
<< std::endl;
std::cout << "event.header.fixed_header.event_type.type_name = "
<< event.header.fixed_header.event_type.type_name
<< std::endl;
try{
ppc->push_structured_event(event);
}
catch (CORBA::SystemException& se)
{
std::cerr << "System exception occurred during push: "
<< se << std::endl;
throw;
//.........这里部分代码省略.........
示例2: main
int main(int argc, char* argv[]) {
char aux1[1000];
time_t seconds;
signal(SIGINT, TerminarEjecucion);
time(&seconds);
srand((unsigned int) seconds);
try {
// Inicializacion del ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "");
// Recoge la referencia al canal
cin >> aux1;
CORBA::Object_var obj = orb->string_to_object(aux1);
// Obtiene el canal
CosNotifyChannelAdmin::EventChannel_var channel;
channel = CosNotifyChannelAdmin::EventChannel::_narrow(obj);
if (CORBA::is_nil(channel)) {
cerr << "[supplier2] ERROR: canal nulo " << endl;
return -1;
}
// Obtiene el SupplierAdmin
CosNotifyChannelAdmin::AdminID id;
_supplier_admin =
channel->new_for_suppliers(CosNotifyChannelAdmin::AND_OP, id);
cerr << "[supplier2] SupplierAdminId = " << id << endl;
CosNotifyChannelAdmin::ProxyID proxy_id;
CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
_supplier_admin->obtain_notification_push_consumer(
CosNotifyChannelAdmin::STRUCTURED_EVENT,
proxy_id);
cerr << "[supplier2] ProxyId = " << proxy_id << endl;
// Obtiene el StructuredProxyPushConsumer
_consumer =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxy_consumer);
try{
CosNotifyComm::StructuredPushSupplier_var supplier =
CosNotifyComm::StructuredPushSupplier::_nil();
_consumer->connect_structured_push_supplier(supplier);
if (_consumer == NULL) cerr << "[supplier2] consumer NULO 5" << endl;
} catch (CORBA::Exception& exc) {
cerr << "[supplier2] Exception in _consumer->connect_push_supplier(...)";
cerr << exc << endl;
} catch (...) {
cerr << "[supplier2] Unknowed exception ";
cerr << "in _consumer->connect_push_supplier(...)";
}
#ifdef _TAO
sleep(1);
#elif defined _TIDORB
TIDThr::Thread::sleep(1000); // 1 ''
#endif
cerr << "[supplier2] Crea un structured event" << flush << endl;
try{
CosNotification::StructuredEvent* event = NULL;
int rnd = 0;
for(int i=0; i < 200; i++) {
rnd = rand();
TimeBase::UtcT current_utc = TIDorb::core::util::Time::currentUtcT();
TimeBase::UtcT future_utc = TIDorb::core::util::Time::currentUtcT();
TimeBase::UtcT pass_utc = TIDorb::core::util::Time::currentUtcT();
future_utc.time += (5 * 10000000); // now + 5 ''
pass_utc.time -= (5 * 10000000); // now - 5 ''
// Rellenamos la informacion del evento
event = new CosNotification::StructuredEvent();
event->header.fixed_header.event_name =
(rnd % 2) ? CORBA::string_dup("event_name") : CORBA::string_dup("other");
event->header.fixed_header.event_type.domain_name =
(rnd % 2) ? CORBA::string_dup("domain_name") : CORBA::string_dup("other");
event->header.fixed_header.event_type.type_name =
(rnd % 2) ? CORBA::string_dup("type_name") : CORBA::string_dup("other");
event->header.variable_header.length(5);
event->header.variable_header[0].name = CORBA::string_dup("EventReliability");
event->header.variable_header[0].value <<= (CORBA::Short) 0;
event->header.variable_header[1].name = CORBA::string_dup("Priority");
//.........这里部分代码省略.........