Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / DevGuideExamples / Messaging / AMIcallback / MessengerHandler.cpp
blobf2e1d7865b6b8f4646a7313f3079bce2a221a4b7
1 #include "MessengerHandler.h"
2 #include "ace/OS_NS_time.h"
3 #include <iostream>
5 // Implementation skeleton constructor
6 MessengerHandler::MessengerHandler (CORBA::ORB_ptr orb)
7 : time_(0)
8 , orb_(CORBA::ORB::_duplicate(orb))
12 // Implementation skeleton destructor
13 MessengerHandler::~MessengerHandler ()
17 void MessengerHandler::send_message (
18 CORBA::Boolean ami_return_val,
19 const char * message,
20 CORBA::Long time
23 if (ami_return_val)
25 time_ = time;
26 time_t t = time_;
27 const ACE_TCHAR * time_str = ACE_OS::ctime(&t);
28 if (time_str != 0) {
29 std::cout << std::endl << "Message sent at " <<
30 ACE_TEXT_ALWAYS_CHAR (time_str) << std::endl;
32 std::cout << "Content of message: " << message << std::endl;
34 else
36 std::cerr << "Error: Message was not sent." << std::endl;
38 // Our simple test just shuts down after sending one message.
39 orb_->shutdown(false);
42 void MessengerHandler::send_message_excep (Messaging::ExceptionHolder* excep_holder)
44 // We'll print an error message and shut down the orb
45 try
47 excep_holder->raise_exception();
49 catch(const CORBA::Exception& ex)
51 std::cerr << "A CORBA Exception was thrown: " << ex << std::endl;
53 orb_->shutdown(false);