1 // Implements a PushConsumer.
3 #include "EchoEventConsumer_i.h"
4 #include "tao/PortableServer/PS_CurrentC.h"
7 EchoEventConsumer_i::EchoEventConsumer_i(
9 CosEventChannelAdmin::ProxyPushSupplier_ptr supplier
,
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();
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());