2 #include "Stock_Consumer.h"
4 #include "ace/streams.h"
6 Stock_Consumer::Stock_Consumer ()
11 Stock_Consumer::connect (CosEventChannelAdmin::EventChannel_ptr event_channel
)
13 CosEventChannelAdmin::ConsumerAdmin_var consumer_admin
=
14 event_channel
->for_consumers ();
16 this->supplier_proxy_
=
17 consumer_admin
->obtain_push_supplier ();
19 CosEventComm::PushConsumer_var myself
= this->_this ();
20 this->supplier_proxy_
->connect_push_consumer (myself
.in ());
24 Stock_Consumer::disconnect ()
26 // Do not receive any more events...
27 this->supplier_proxy_
->disconnect_push_supplier ();
31 Stock_Consumer::push (const CORBA::Any
& data
)
33 const Quoter::Event
*event
= 0;
34 if ((data
>>= event
) == 0)
35 return; // Invalid event
37 cout
<< "The new price for one stock in \""
38 << event
->full_name
.in ()
39 << "\" (" << event
->symbol
.in ()
40 << ") is " << event
->price
<< endl
;
44 Stock_Consumer::disconnect_push_consumer ()
46 this->supplier_proxy_
= CosEventChannelAdmin::ProxyPushSupplier::_nil ();