1 #include "ClientInterceptor.h"
2 #include "tao/OctetSeqC.h"
3 #include "tao/PI/ClientRequestInfo.h"
4 #include "MessengerC.h"
5 #include "ace/OS_NS_string.h"
8 const CORBA::ULong service_ctx_id
= 0xdeed;
11 ClientInterceptor (Messenger_var theMessenger
,
12 PortableInterceptor::Current_ptr thePic
,
13 PortableInterceptor::SlotId theSlot
)
14 : myname_ ("Client_Authentication_Interceptor")
16 std::cout
<< "Calling ClientInterceptor constructor." << std::endl
;
17 this->messenger
= theMessenger
;
22 ClientInterceptor::~ClientInterceptor (void)
27 ClientInterceptor::name ()
29 std::cout
<< "Calling ClientInterceptor name() method" << std::endl
;
30 return CORBA::string_dup (this->myname_
);
34 ClientInterceptor::destroy ()
39 ClientInterceptor::send_poll (PortableInterceptor::ClientRequestInfo_ptr ri
)
42 std::cout
<< "Calling send_poll()." << std::endl
;
47 ClientInterceptor::send_request (PortableInterceptor::ClientRequestInfo_ptr ri
)
49 std::cout
<< "Calling send_request()." << std::endl
;
51 IOP::ServiceContext sc
;
52 sc
.context_id
= service_ctx_id
;
54 const char user_name
[] = "Ron Klein";
55 std::cout
<< "User's Name: " << user_name
<< std::endl
;
56 CORBA::ULong string_len
= sizeof (user_name
) + 1;
57 CORBA::Octet
*buf
= 0;
58 buf
= new CORBA::Octet
[string_len
];
60 ACE_OS::strcpy (reinterpret_cast<char*> (buf
), user_name
);
62 sc
.context_data
.replace (string_len
, string_len
, buf
, true);
64 // recursive call setup
65 CORBA::Any
*recurse
= ri
->get_slot(slot
);
68 if (*recurse
>>= CORBA::Any::to_boolean(x
)) {
72 flag
<<= CORBA::Any::from_boolean(x
);
74 pic
->set_slot(slot
, flag
);
77 std::cout
<< "Server Time = " << messenger
->get_time() << std::endl
;
80 std::cerr
<< "Could not extract a boolean value from any" << std::endl
;
83 // Add this context to the service context list.
84 ri
->add_request_service_context (sc
, false);
86 // reset recursion test
88 flag
<<= CORBA::Any::from_boolean(x
);
89 pic
->set_slot(slot
,flag
);
94 ClientInterceptor::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri
)
97 std::cout
<< "Calling receive_reply()." << std::endl
;
101 ClientInterceptor::receive_other (PortableInterceptor::ClientRequestInfo_ptr ri
)
104 std::cout
<< "Calling receive_other()." << std::endl
;
108 ClientInterceptor::receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri
)
111 std::cout
<< "Calling receive_exception()." << std::endl
;