1 //=============================================================================
3 * Implementation of the Supplier_Time_Handler class.
5 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
7 //=============================================================================
10 #include "Supplier_Timer_Handler.h"
12 // The supplier refernce is got so that the mathods in the supplier
14 Supplier_Timer_Handler:: Supplier_Timer_Handler (Supplier
*supplier
,
17 :supplier_obj_ (supplier
),
23 // Method which will be called by the reactor on timeout.
25 Supplier_Timer_Handler:: handle_timeout (const ACE_Time_Value
& /* tv */,
26 const void * /* arg */)
29 "Sending Stock Market Information to Notifier...\n"));
31 // The next current stock rates are obtained from a file.
32 if (this->get_stock_information () == -1)
36 // Send the stock information to the notifier. Graceful exit when
37 // the notifier doesnt accept the information.
38 if (this->supplier_obj_
->send_market_status (stockname_
,
41 this->reactor_
->end_event_loop ();
42 ACE_ERROR_RETURN ((LM_ERROR
,
43 "handle_timeout: send_market_status failed! %p\n",
44 "send_market_status"),
51 // Get the stock information from a file.
53 Supplier_Timer_Handler::get_stock_information ()
55 // Scan the file and obtain the stock information.
56 if (fscanf (file_ptr_
,
62 "Stockname: %s, Stockvalue: %d\n",
69 // Close down the Reactor.
70 this->reactor_
->end_event_loop ();