1 #include "MessengerC.h"
2 #include "ClientInitializer.h"
4 #include "tao/ORBInitializer_Registry.h"
5 // Ensure that the PI library is linked in when building statically
8 #include "ace/Get_Opt.h"
10 const ACE_TCHAR
*ior
= ACE_TEXT ("file://Messenger.ior");
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
18 while ((c
= get_opts ()) != -1)
22 ior
= get_opts
.opt_arg ();
27 ACE_ERROR_RETURN ((LM_ERROR
,
34 // Indicates successful parsing of the command line
40 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
44 ClientInitializer
* temp_initializer
= new ClientInitializer
;
46 PortableInterceptor::ORBInitializer_var orb_initializer
=
49 PortableInterceptor::register_orb_initializer (orb_initializer
.in ());
51 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
, "Client ORB");
53 if (parse_args (argc
, argv
) != 0)
55 // Now that the ORB is initialized (and subsequently the
56 // PICurrent), we can set the slot data on the PICurrent for our
57 // interceptor initializer.
58 temp_initializer
->set_slot_data ();
60 CORBA::Object_var obj
= orb
->string_to_object( ior
);
61 if ( CORBA::is_nil(obj
.in() ) ) {
62 std::cerr
<< "Nil Messenger reference" << std::endl
;
66 Messenger_var messenger
= Messenger::_narrow( obj
.in() );
67 if( CORBA::is_nil( messenger
.in() ) ) {
68 std::cerr
<< "Not a Messenger reference" << std::endl
;
72 CORBA::String_var message
= CORBA::string_dup( "Hello!" );
73 messenger
->send_message( "TAO User", "TAO Test", message
.inout() );
76 catch(const CORBA::Exception
& ex
)
78 std::cerr
<< "client Caught CORBA exception: " << ex
<< std::endl
;