1 #include "ClientInterceptor.h"
2 #include "tao/OctetSeqC.h"
3 #include "tao/LocalObject.h"
4 #include "tao/PI/ClientRequestInfo.h"
8 const CORBA::ULong service_ctx_id
= 0xdeed;
11 ClientInterceptor (IOP::CodecFactory_var cf
)
12 : myname_ ("Client_Authentication_Interceptor")
14 std::cout
<< "Calling ClientInterceptor constructor." << std::endl
;
16 // Set up a structure that contains information necessary to
17 // create a GIOP 1.2 CDR encapsulation Codec.
18 IOP::Encoding encoding
;
19 encoding
.format
= IOP::ENCODING_CDR_ENCAPS
;
20 encoding
.major_version
= 1;
21 encoding
.minor_version
= 2;
23 // Obtain the CDR encapsulation Codec.
24 this->codec
= cf
->create_codec (encoding
);
27 ClientInterceptor::~ClientInterceptor ()
32 ClientInterceptor::name ()
34 std::cout
<< "Calling ClientInterceptor name() method" << std::endl
;
35 return CORBA::string_dup (this->myname_
);
39 ClientInterceptor::destroy ()
44 ClientInterceptor::send_poll (
45 PortableInterceptor::ClientRequestInfo_ptr ri
)
48 std::cout
<< "Calling send_poll()." << std::endl
;
53 ClientInterceptor::send_request (
54 PortableInterceptor::ClientRequestInfo_ptr ri
)
56 std::cout
<< "Calling send_request()." << std::endl
;
58 const CORBA::ULong tagID
= 9654;
62 IOP::TaggedComponent_var myTag
= ri
->get_effective_component(tagID
);
64 reinterpret_cast<char*> (myTag
->component_data
.get_buffer());
66 std::cout
<< "IOR Tag is : " << tag
<< std::endl
;
70 std::cerr
<< "Tagged Component not found" << std::endl
;
73 IOP::ServiceContext sc
;
74 sc
.context_id
= service_ctx_id
;
76 const CORBA::Long gid
= 9007;
78 std::cout
<< "GID: " << gid
<< std::endl
;
80 CORBA::Any gid_as_any
;
83 sc
.context_data
= *codec
->encode(gid_as_any
);
85 // Add this context to the service context list.
86 ri
->add_request_service_context (sc
, false);
90 ClientInterceptor::receive_reply (
91 PortableInterceptor::ClientRequestInfo_ptr ri
)
94 std::cout
<< "Calling receive_reply()." << std::endl
;
98 ClientInterceptor::receive_other (
99 PortableInterceptor::ClientRequestInfo_ptr ri
)
102 std::cout
<< "Calling receive_other()." << std::endl
;
106 ClientInterceptor::receive_exception (
107 PortableInterceptor::ClientRequestInfo_ptr ri
)
110 std::cout
<< "Calling receive_exception()." << std::endl
;