1 #include "MessengerC.h"
2 #include "ClientInitializer.h"
3 #include "tao/ORBInitializer_Registry.h"
4 // Ensure that the PI library is linked in when building statically
7 #include "ace/Get_Opt.h"
9 const ACE_TCHAR
*ior
= ACE_TEXT ("file://Messenger.ior");
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
26 ACE_ERROR_RETURN ((LM_ERROR
,
33 // Indicates successful parsing of the command line
38 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
42 PortableInterceptor::ORBInitializer_var orb_initializer
=
43 new ClientInitializer
;
45 PortableInterceptor::register_orb_initializer (orb_initializer
.in ());
47 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
, "Client ORB");
49 if (parse_args (argc
, argv
) != 0)
52 CORBA::Object_var obj
= orb
->string_to_object( ior
);
54 if ( CORBA::is_nil(obj
.in() ) ) {
55 std::cerr
<< "Nil Messenger reference" << std::endl
;
59 Messenger_var messenger
= Messenger::_narrow( obj
.in() );
61 if( CORBA::is_nil( messenger
.in() ) ) {
62 std::cerr
<< "Not a Messenger reference" << std::endl
;
66 CORBA::String_var message
= CORBA::string_dup( "Hello!" );
67 messenger
->send_message( "TAO User", "TAO Test", message
.inout() );
69 catch(const CORBA::Exception
& ex
)
71 std::cerr
<< "Caught CORBA exception: " << ex
<< std::endl
;