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