summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventConsumer_i.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventConsumer_i.cpp')
-rw-r--r--TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventConsumer_i.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventConsumer_i.cpp b/TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventConsumer_i.cpp
new file mode 100644
index 00000000000..68515ac1a09
--- /dev/null
+++ b/TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventConsumer_i.cpp
@@ -0,0 +1,54 @@
+// $Id$
+
+// EchoEventConsumer_i.cpp
+// Implements a PushConsumer.
+
+#include "EchoEventConsumer_i.h"
+#include "tao/PortableServer/PS_CurrentC.h"
+#include "ace/OS_NS_stdio.h"
+
+#include <sstream>
+
+// Constructor duplicates the ORB reference.
+EchoEventConsumer_i::EchoEventConsumer_i(CORBA::ORB_ptr orb, int event_limit)
+ : orb_(CORBA::ORB::_duplicate(orb))
+ , event_limit_(event_limit)
+{
+ // Nothing to do.
+}
+
+// Implement the push() operation.
+void EchoEventConsumer_i::push(const RtecEventComm::EventSet& events)
+ throw(CORBA::SystemException)
+{
+ // Loop through the events, looking for shutdown events.
+ for (u_int i = 0; i < events.length (); ++i) {
+ //ACE_OS::printf(".");
+ // Extract event data from the any.
+ const char* eventData;
+ std::ostringstream out;
+ out << "Received event,"
+ << " type: " << events[i].header.type
+ << " source: " << events[i].header.source;
+ if (events[i].data.any_value >>= eventData) {
+ out << " text: " << eventData;
+ }
+
+ ACE_OS::printf("%s\n", out.str().c_str()); // printf is synchronized
+ }
+ if (--event_limit_ <= 0) {
+ orb_->shutdown(0);
+ }
+}
+
+// Implement the disconnect_push_consumer() operation.
+void EchoEventConsumer_i::disconnect_push_consumer()
+ throw(CORBA::SystemException)
+{
+ // Deactivate this object.
+ CORBA::Object_var obj = orb_->resolve_initial_references("POACurrent");
+ PortableServer::Current_var current = PortableServer::Current::_narrow(obj.in());
+ PortableServer::POA_var poa = current->get_POA();
+ PortableServer::ObjectId_var objectId = current->get_object_id();
+ poa->deactivate_object(objectId.in());
+}