1 #include "MessengerC.h"
2 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
8 int parse_args (int argc
, ACE_TCHAR
* argv
[])
10 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:x"));
13 while ((c
= get_opts ()) != -1)
18 ior
= get_opts
.opt_arg ();
25 ACE_ERROR_RETURN ((LM_ERROR
,
28 "-x - call shutdown on server\n",
36 int ACE_TMAIN( int argc
, ACE_TCHAR
* argv
[] )
39 // Initialize the ORB.
40 CORBA::ORB_var orb
= CORBA::ORB_init(argc
, argv
);
43 if (parse_args (argc
, argv
) != 0)
46 // Read and destringify the Messenger object's IOR.
47 CORBA::Object_var obj
= orb
->string_to_object(ior
);
48 if( CORBA::is_nil( obj
.in() ) ) {
49 std::cerr
<< "Could not get Messenger IOR." << std::endl
;
53 // Narrow the IOR to a Messenger object reference.
54 Messenger_var messenger
= Messenger::_narrow( obj
.in() );
55 if( CORBA::is_nil( messenger
.in() ) ) {
56 std::cerr
<< "IOR was not a Messenger object reference." << std::endl
;
60 // Send a message the the Messenger object.
61 CORBA::String_var message
= CORBA::string_dup( "Hello!" );
62 messenger
->send_message( "TAO User", "TAO Test", message
.inout() );
64 // Print the Messenger's reply.
65 std::cout
<< "Reply: " << message
.in() << std::endl
;
68 if (call_shutdown
== 1)
70 messenger
->shutdown();
76 catch(const CORBA::Exception
& ex
) {
77 std::cerr
<< "CORBA exception: " << ex
<< std::endl
;