2 // File : NOTIFICATION_Consumer.cxx
3 // Created : 1 Avril 2002
4 // Author : Laurent DADA / Francis KLOSS
6 // Module : Notification Consumer
7 // Copyright : CEA / Open CASCADE
9 #include "NOTIFICATION.hxx"
11 NOTIFICATION_Consumer::NOTIFICATION_Consumer():
15 CosNA_EventChannel_ptr channel = NOTIFICATION_channel();
16 if (CORBA::is_nil(channel)) {
17 MESSAGE("NOTIFICATION Error : failed to get channel for consumer");
19 CosNA_ConsumerAdmin_ptr consumerAdmin = channel->default_consumer_admin();
21 CosNA_ProxyID proxyId;
22 CosNotifyChannelAdmin::ProxySupplier_ptr supplier = consumerAdmin->obtain_notification_pull_supplier(CosNA_STRUCTURED_EVENT, proxyId);
23 if (CORBA::is_nil(supplier)) {
24 MESSAGE("NOTIFICATION Error : failed to get proxy pull supplier");
26 proxy_supplier = CosNA_StructuredProxyPullSupplier::_narrow(supplier);
27 if (CORBA::is_nil(proxy_supplier)) {
28 MESSAGE("NOTIFICATION Error : failed to _narrow proxy pull supplier");
31 proxy_supplier->connect_structured_pull_consumer(_this());
33 MESSAGE("NOTIFICATION Info : successfully connection for pull consumer notification");
34 } catch (CORBA::BAD_PARAM& ex) {
35 MESSAGE("NOTIFICATION Error : pull consumer BAD_PARAM exception while connecting");
36 } catch (CosEventChannelAdmin::AlreadyConnected& ex) {
37 MESSAGE("NOTIFICATION Error : pull consumer already connected");
39 MESSAGE("NOTIFICATION Error : pull consumer failed to connect");
46 NOTIFICATION_Consumer::~NOTIFICATION_Consumer() {
49 CosNA_StructuredProxyPullSupplier_var proxy = proxy_supplier;
50 proxy_supplier = CosNA_StructuredProxyPullSupplier::_nil();
53 if (!CORBA::is_nil(proxy)) {
54 proxy->disconnect_structured_pull_supplier();
57 MESSAGE("NOTIFICATION Error : while disconnecting proxy pull supplier");
62 bool NOTIFICATION_Consumer::Receive(char** graph, char** node, char** type, char** message, char** sender, long* counter, char** date, long* stamp) {
64 CORBA::Boolean has_event;
65 CosN_StructuredEvent* event;
69 event = proxy_supplier->try_pull_structured_event(has_event);
72 MESSAGE("NOTIFICATION Error : while calling try_pull_structured_event");
79 CORBA::ULong Acounter;
84 event->filterable_data[0].value >>= Asender;
85 event->filterable_data[1].value >>= Agraph;
86 event->filterable_data[2].value >>= Atype;
87 event->filterable_data[3].value >>= Acounter;
88 event->filterable_data[4].value >>= Adate;
89 event->filterable_data[5].value >>= Anode;
90 event->filterable_data[6].value >>= Astamp;
91 event->remainder_of_body >>= Amessage;
92 *graph = strdup(Agraph);
93 *node = strdup(Anode);
94 *type = strdup(Atype);
95 *message = strdup(Amessage);
96 *sender = strdup(Asender);
97 *counter = (long)Acounter;
98 *date = strdup(Adate);
99 *stamp = (long)Astamp;
106 void NOTIFICATION_Consumer::disconnect_structured_pull_consumer() {
109 void NOTIFICATION_Consumer::offer_change(const CosN_EventTypeSeq& added, const CosN_EventTypeSeq& deled) {