1 // ******************************************************************
3 // ******************************************************************
5 #include "ace/Get_Opt.h"
6 #include "ace/OS_NS_unistd.h"
9 #include "Notify_Structured_Push_Consumer.h"
10 #include "Notify_Test_Client.h"
12 // ******************************************************************
14 // ******************************************************************
16 static const ACE_TCHAR
* ior
= ACE_TEXT("file://supplier.ior");
17 static unsigned int expected
= 2;
18 static Notify_Structured_Push_Consumer
* consumer_1
= 0;
20 class Consumer_Client
: public Notify_Test_Client
23 virtual int parse_args (int argc
, ACE_TCHAR
* argv
[]);
28 Consumer_Client::parse_args (int argc
, ACE_TCHAR
*argv
[])
30 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
33 while ((c
= get_opts ()) != -1)
37 ior
= get_opts
.optarg
;
41 ACE_ERROR_RETURN ((LM_ERROR
,
48 // Indicates successful parsing of the command line
53 static CosNotifyChannelAdmin::ConsumerAdmin_ptr
54 create_consumeradmin (CosNotifyChannelAdmin::EventChannel_ptr ec
)
56 CosNotifyChannelAdmin::AdminID adminid
= 0;
57 CosNotifyChannelAdmin::ConsumerAdmin_var admin
=
58 ec
->new_for_consumers (CosNotifyChannelAdmin::OR_OP
, adminid
);
60 return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (admin
.in ());
65 create_consumers (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin
,
66 Notify_Test_Client
* client
)
68 // startup the consumer
69 ACE_NEW_THROW_EX (consumer_1
,
70 Notify_Structured_Push_Consumer ("consumer1",
74 consumer_1
->init (client
->root_poa ());
75 consumer_1
->_connect (admin
);
78 // ******************************************************************
80 // ******************************************************************
82 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
87 Consumer_Client client
;
89 status
= client
.init (argc
, argv
);
91 ACE_ERROR_RETURN ((LM_ERROR
, "Error: Client init failed.\n"),1);
93 CosNotifyChannelAdmin::EventChannel_var ec
=
94 client
.create_event_channel ("MyEventChannel", 1);
96 CORBA::ORB_ptr orb
= client
.orb ();
97 CORBA::Object_var object
=
98 orb
->string_to_object (ior
);
100 sig_var sig
= sig::_narrow (object
.in ());
102 CosNotifyChannelAdmin::ConsumerAdmin_var admin
=
103 create_consumeradmin (ec
.in ());
105 if (CORBA::is_nil (admin
.in ()))
106 ACE_ERROR_RETURN ((LM_ERROR
, "Error: nil ConsumerAdmin.\n"),1);
108 create_consumers (admin
.in (), &client
);
110 ACE_DEBUG ((LM_DEBUG
, "\nConsumer waiting for events...\n"));
113 ACE_Time_Value
tv (5);
116 ACE_DEBUG ((LM_DEBUG
, "Consumer done.\n"));
118 catch (const CORBA::Exception
& e
)
120 e
._tao_print_exception ("Consumer Error: ");