1 #include "TestBroadcaster.h"
3 TestBroadcaster::TestBroadcaster()
7 TestBroadcaster::~TestBroadcaster() noexcept
9 // ensure nothrow guarantee
19 bool TestBroadcaster::connect(
21 std::string
const & rc_channelIor
)
25 CosNotifyChannelAdmin::EventChannel_var v_eventChannel
;
26 CosNotifyChannelAdmin::SupplierAdmin_var v_supplierAdmin
;
27 CosNotifyChannelAdmin::ProxyConsumer_var v_proxyConsumer
;
28 CosNotifyChannelAdmin::AdminID supplierAdminId
;
29 CosNotifyChannelAdmin::ProxyID proxyConsumerId
;
31 CORBA::Object_var v_obj
= p_orb
->string_to_object(rc_channelIor
.c_str());
33 v_eventChannel
= CosNotifyChannelAdmin::EventChannel::_narrow(v_obj
.in());
36 v_eventChannel
->new_for_suppliers (
37 CosNotifyChannelAdmin::OR_OP
,
40 v_proxyConsumer
= v_supplierAdmin
->obtain_notification_push_consumer(
41 CosNotifyChannelAdmin::SEQUENCE_EVENT
,
44 mv_sequenceProxyPushConsumer
=
45 CosNotifyChannelAdmin::SequenceProxyPushConsumer::_narrow(
46 v_proxyConsumer
.in());
48 mv_sequenceProxyPushConsumer
->connect_sequence_push_supplier(
49 CosNotifyComm::SequencePushSupplier::_nil());
59 bool TestBroadcaster::disconnect()
65 mv_sequenceProxyPushConsumer
->disconnect_sequence_push_consumer();
66 mv_sequenceProxyPushConsumer
= CosNotifyChannelAdmin::SequenceProxyPushConsumer_var();
75 } /* end of TestBroadcaster::disconnect */
78 bool TestBroadcaster::sendData()
82 CosNotification::EventBatch events
;
85 for (CORBA::ULong idx
= 0, max
= events
.length(); idx
< max
; ++idx
)
87 events
[idx
].header
.fixed_header
.event_type
.domain_name
= "Test";
88 events
[idx
].header
.fixed_header
.event_type
.type_name
= "Data";
89 events
[idx
].header
.fixed_header
.event_name
= "Info";
90 events
[idx
].header
.variable_header
.length(0);
92 // provide filter criteria
93 events
[idx
].filterable_data
.length(1);
94 events
[idx
].filterable_data
[0].name
= "data";
95 events
[idx
].filterable_data
[0].value
<<= idx
;
97 events
[idx
].remainder_of_body
<<= idx
;
100 mv_sequenceProxyPushConsumer
->push_structured_events(events
);
110 bool TestBroadcaster::isConnected() const
112 return !CORBA::is_nil(mv_sequenceProxyPushConsumer
.in());