1 // Reused from: $TAO_ROOT/orbsvcs/examples/RtEC/MCast
4 #include "orbsvcs/RtecEventChannelAdminS.h"
5 #include "orbsvcs/Event_Service_Constants.h"
13 Consumer::connect (RtecEventChannelAdmin::ConsumerAdmin_ptr consumer_admin
)
16 consumer_admin
->obtain_push_supplier ();
18 RtecEventComm::PushConsumer_var me
=
21 // Simple subscription, but usually the helper classes in
22 // $TAO_ROOT/orbsvcs/Event_Utils.h are a better way to do this.
23 RtecEventChannelAdmin::ConsumerQOS qos
;
26 qos
.dependencies
.length (2);
27 RtecEventComm::EventHeader
& h0
=
28 qos
.dependencies
[0].event
.header
;
29 h0
.type
= ACE_ES_DISJUNCTION_DESIGNATOR
;
30 h0
.source
= 1; // The disjunction has one element
32 RtecEventComm::EventHeader
& h1
=
33 qos
.dependencies
[1].event
.header
;
34 h1
.type
= ACE_ES_EVENT_UNDEFINED
; // first free event type
35 h1
.source
= ACE_ES_EVENT_SOURCE_ANY
; // Any source is OK
37 this->proxy_
->connect_push_consumer (me
.in (), qos
);
41 Consumer::disconnect ()
45 // Disconnect from the proxy
46 this->proxy_
->disconnect_push_supplier ();
48 catch (const CORBA::Exception
&)
52 this->proxy_
= RtecEventChannelAdmin::ProxyPushSupplier::_nil ();
54 // Deactivate this object
55 PortableServer::POA_var poa
=
56 this->_default_POA ();
57 // Get the Object Id used for the servant..
58 PortableServer::ObjectId_var oid
=
59 poa
->servant_to_id (this);
60 // Deactivate the object
61 poa
->deactivate_object (oid
.in ());
65 Consumer::push (const RtecEventComm::EventSet
& events
)
67 if (events
.length () == 0)
70 "Consumer (%P|%t) no events\n"));
74 this->event_count_
+= events
.length ();
75 if (this->event_count_
% 10000 == 0)
78 "Consumer (%P|%t): %d events received\n",
84 Consumer::disconnect_push_consumer ()