summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/RtEC/MCast/Supplier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/examples/RtEC/MCast/Supplier.cpp')
-rw-r--r--TAO/orbsvcs/examples/RtEC/MCast/Supplier.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/TAO/orbsvcs/examples/RtEC/MCast/Supplier.cpp b/TAO/orbsvcs/examples/RtEC/MCast/Supplier.cpp
new file mode 100644
index 00000000000..f835dcb6daa
--- /dev/null
+++ b/TAO/orbsvcs/examples/RtEC/MCast/Supplier.cpp
@@ -0,0 +1,94 @@
+// $Id$
+
+#include "Supplier.h"
+#include "orbsvcs/RtecEventChannelAdminS.h"
+#include "orbsvcs/Event_Service_Constants.h"
+
+ACE_RCSID (EC_Examples,
+ Supplier,
+ "$Id$")
+
+Supplier::Supplier (void)
+{
+}
+
+void
+Supplier::connect (RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin
+ ACE_ENV_ARG_DECL)
+{
+ this->proxy_ =
+ supplier_admin->obtain_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ RtecEventComm::PushSupplier_var me =
+ this->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // Simple publication, but usually the helper classes in
+ // $TAO_ROOT/orbsvcs/Event_Utils.h are a better way to do this.
+ RtecEventChannelAdmin::SupplierQOS qos;
+ qos.is_gateway = 0;
+
+ qos.publications.length (1);
+ RtecEventComm::EventHeader& h0 =
+ qos.publications[0].event.header;
+ h0.type = ACE_ES_EVENT_UNDEFINED; // first free event type
+ h0.source = 1; // first free event source
+
+ this->proxy_->connect_push_supplier (me.in (), qos
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+Supplier::disconnect (ACE_ENV_SINGLE_ARG_DECL)
+{
+ // Disconnect from the EC
+ ACE_TRY
+ {
+ this->proxy_->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ }
+ ACE_ENDTRY;
+
+ PortableServer::POA_var poa =
+ this->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+ PortableServer::ObjectId_var id =
+ poa->servant_to_id (this ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ poa->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+Supplier::perform_push (ACE_ENV_SINGLE_ARG_DECL)
+{
+ ACE_TRY
+ {
+ // The event type and source must match our publications
+ RtecEventComm::EventSet event (1);
+ event.length (1);
+ event[0].header.type = ACE_ES_EVENT_UNDEFINED;
+ event[0].header.source = 1;
+ // Avoid loops throught the event channel federations
+ event[0].header.ttl = 1;
+
+ this->proxy_->push (event ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ }
+ ACE_ENDTRY;
+}
+
+void
+Supplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+