Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / EventServices / OMG_Basic / EchoEventConsumer_i.cpp
blobd4035549bcbdda6482c88365f18a99e433b64a5b
1 // Implements a PushConsumer.
3 #include "EchoEventConsumer_i.h"
4 #include "tao/PortableServer/PS_CurrentC.h"
5 #include <iostream>
7 EchoEventConsumer_i::EchoEventConsumer_i(
8 CORBA::ORB_ptr orb,
9 CosEventChannelAdmin::ProxyPushSupplier_ptr supplier,
10 int event_limit)
11 : orb_(CORBA::ORB::_duplicate(orb))
12 , supplier_(CosEventChannelAdmin::ProxyPushSupplier::_duplicate(supplier))
13 , event_limit_(event_limit)
17 // Override the push() operation.
18 void EchoEventConsumer_i::push(const CORBA::Any & data)
20 // Extract event data from the any.
21 const char* eventData;
22 if (data >>= eventData)
24 std::cout << "EchoEventConsumer_i::push(): Received event: "
25 << eventData << std::endl;
27 if (--event_limit_ <= 0) {
28 supplier_->disconnect_push_supplier();
29 orb_->shutdown(0);
33 // Override the disconnect_push_consumer() operation.
34 void EchoEventConsumer_i::disconnect_push_consumer()
36 // Deactivate this object.
37 CORBA::Object_var obj = orb_->resolve_initial_references("POACurrent");
38 PortableServer::Current_var current = PortableServer::Current::_narrow(obj.in());
39 PortableServer::POA_var poa = current->get_POA();
40 PortableServer::ObjectId_var objectId = current->get_object_id();
41 poa->deactivate_object(objectId.in());