3 // ****** Code generated by the The ACE ORB (TAO) IDL Compiler *******
4 // TAO and the TAO IDL Compiler have been developed by the Center for
5 // Distributed Object Computing at Washington University, St. Louis.
7 // Information about TAO is available at:
8 // http://www.dre.vanderbilt.edu/~schmidt/TAO.html
10 #include "Messenger_i.h"
11 #include "ace/OS_NS_unistd.h"
12 #include "ace/OS_NS_sys_time.h"
14 // Implementation skeleton constructor
15 Messenger_i::Messenger_i (unsigned int seconds_to_wait
,
16 CORBA::Boolean throw_exception
)
17 : seconds_to_wait_(seconds_to_wait
)
18 , throw_exception_(throw_exception
)
22 // Implementation skeleton destructor
23 Messenger_i::~Messenger_i ()
27 CORBA::Boolean
Messenger_i::send_message (
28 const char * user_name
,
31 CORBA::Long_out time_sent
36 std::cout
<< "Throwing MessengerUnableToSendMessage exception." << std::endl
;
37 throw MessengerUnableToSendMessage();
40 std::cout
<< "Write a letter to " << user_name
<< " as follows:" << std::endl
;
41 std::cout
<< "Subject: " << subject
<< std::endl
;
42 std::cout
<< "Dear " << user_name
<< ',' << std::endl
;
43 std::cout
<< message
<< std::endl
;
45 if (seconds_to_wait_
> 0)
47 std::cout
<< "Waiting for " << seconds_to_wait_
<< " seconds..." << std::flush
;
48 ACE_OS::sleep(seconds_to_wait_
);
49 std::cout
<< " Done waiting" << std::endl
;
52 // Record the time the message was sent
53 time_sent
= static_cast<CORBA::Long
> (ACE_OS::gettimeofday().sec());
55 // We will assume the message has been sent, so return true