1 // ******************************************************************
3 // ******************************************************************
5 #include "Notify_Push_Consumer.h"
7 #include "Notify_Test_Client.h"
9 #include "ace/Get_Opt.h"
10 #include "ace/Argv_Type_Converter.h"
12 // ******************************************************************
14 // ******************************************************************
16 static const ACE_TCHAR
* ior
= ACE_TEXT ("file://supplier.ior");
17 static Notify_Sequence_Push_Consumer
* consumer_1
;
18 static bool go
= false;
20 // ******************************************************************
22 // ******************************************************************
24 class Consumer_Client
: public Notify_Test_Client
27 virtual int parse_args (int argc
, ACE_TCHAR
* argv
[]);
32 Consumer_Client::parse_args (int argc
, ACE_TCHAR
*argv
[])
34 ACE_Argv_Type_Converter
argcon (argc
, argv
);
35 ACE_Get_Opt
get_opts (argcon
.get_argc (),
36 argcon
.get_TCHAR_argv (), ACE_TEXT ("gk:"));
39 while ((c
= get_opts ()) != -1)
46 ior
= get_opts
.optarg
;
50 ACE_ERROR_RETURN ((LM_ERROR
,
58 // Indicates successful parsing of the command line
63 static CosNotifyChannelAdmin::ConsumerAdmin_ptr
64 create_consumeradmin (CosNotifyChannelAdmin::EventChannel_ptr ec
)
66 CosNotifyChannelAdmin::AdminID adminid
= 0;
67 CosNotifyChannelAdmin::ConsumerAdmin_var admin
=
68 ec
->new_for_consumers (CosNotifyChannelAdmin::OR_OP
,
72 return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (admin
.in ());
77 create_consumers (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin
,
78 Notify_Test_Client
* client
)
80 // startup the consumer
81 ACE_NEW_THROW_EX (consumer_1
,
82 Notify_Sequence_Push_Consumer (*client
),
84 consumer_1
->init (client
->root_poa ());
86 consumer_1
->_connect (admin
);
89 // ******************************************************************
91 // ******************************************************************
94 ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
99 Consumer_Client client
;
100 ACE_Argv_Type_Converter
argcon (argc
, argv
);
101 status
= client
.init (argcon
.get_argc (), argcon
.get_TCHAR_argv ());
105 CosNotifyChannelAdmin::EventChannel_var ec
=
106 client
.create_event_channel ("MyEventChannel", 1);
108 CORBA::ORB_ptr orb
= client
.orb ();
109 CORBA::Object_var object
=
110 orb
->string_to_object (ior
);
112 sig_var sig
= sig::_narrow (object
.in ());
114 if (CORBA::is_nil (sig
.in ()))
116 ACE_ERROR_RETURN ((LM_ERROR
,
117 "Object reference <%s> is nil\n",
122 CosNotifyChannelAdmin::ConsumerAdmin_var admin
=
123 create_consumeradmin (ec
.in ());
125 if (!CORBA::is_nil (admin
.in ()))
127 create_consumers (admin
.in (), &client
);
130 // Tell the supplier to go
134 ACE_DEBUG ((LM_DEBUG
, "Consumer waiting for events...\n"));
138 ACE_DEBUG ((LM_DEBUG
, "Consumer done.\n"));
139 consumer_1
->disconnect ();
148 catch (const CORBA::Exception
& e
)
150 e
._tao_print_exception ("Error: ");