Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / NotifyService / Messenger / MessengerConsumer.cpp
blobb596d076974ac5bc2e389c3c45a12c9dc89da485
1 #include "orbsvcs/CosNotifyChannelAdminC.h"
2 #include "orbsvcs/CosNotifyCommC.h"
3 #include "orbsvcs/CosNamingC.h"
5 #include "StructuredEventConsumer_i.h"
6 #include <iostream>
8 int
9 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
11 try
13 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
15 CORBA::Object_var naming_obj =
16 orb->resolve_initial_references ("NameService");
18 CosNaming::NamingContext_var naming_context =
19 CosNaming::NamingContext::_narrow(naming_obj.in());
21 CosNaming::Name name;
22 name.length (1);
23 name[0].id = CORBA::string_dup("MyEventChannel");
24 CORBA::Object_var ecObj = naming_context->resolve(name);
26 CosNotifyChannelAdmin::EventChannel_var ec =
27 CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());
29 CosNotifyChannelAdmin::AdminID adminid;
30 CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
31 CosNotifyChannelAdmin::AND_OP;
33 CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
34 ec->new_for_consumers(ifgop,
35 adminid);
37 CORBA::Object_var poa_object =
38 orb->resolve_initial_references("RootPOA");
40 PortableServer::POA_var poa =
41 PortableServer::POA::_narrow (poa_object.in());
43 PortableServer::Servant_var<StructuredEventConsumer_i> servant =
44 new StructuredEventConsumer_i(orb.in());
46 PortableServer::ObjectId_var objectId = poa->activate_object (servant.in());
48 CORBA::Object_var consumer_obj = poa->id_to_reference (objectId.in ());
50 CosNotifyComm::StructuredPushConsumer_var consumer =
51 CosNotifyComm::StructuredPushConsumer::_narrow (consumer_obj.in ());
53 CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;
55 CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
56 consumer_admin->obtain_notification_push_supplier(
57 CosNotifyChannelAdmin::STRUCTURED_EVENT,
58 consumeradmin_proxy_id);
60 CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;
61 supplier_proxy = CosNotifyChannelAdmin::StructuredProxyPushSupplier::
62 _narrow(proxy_supplier.in());
64 supplier_proxy->connect_structured_push_consumer(consumer.in());
66 CosNotification::EventTypeSeq added (1);
67 CosNotification::EventTypeSeq removed (1);
68 added.length (1);
69 removed.length (1);
71 added[0].domain_name = CORBA::string_dup ("OCI_TAO");
72 added[0].type_name = CORBA::string_dup ("examples");
74 removed[0].domain_name = CORBA::string_dup ("*");
75 removed[0].type_name = CORBA::string_dup ("*");
77 supplier_proxy->subscription_change(added, removed);
79 PortableServer::POAManager_var poa_manager = poa->the_POAManager();
81 poa_manager->activate();
83 orb->run();
85 catch(const CORBA::Exception& ex)
87 std::cerr << "Caught exception: " << ex << std::endl;
88 return 1;
91 return 0;