1 #include "ClientInterceptor.h"
2 #include "tao/OctetSeqC.h"
3 #include "tao/PI/ClientRequestInfo.h"
6 const CORBA::ULong service_ctx_id
= 0xdeed;
9 ClientInterceptor (IOP::CodecFactory_var cf
)
10 : myname_ ("Client_Authentication_Interceptor")
12 std::cout
<< "Calling ClientInterceptor constructor." << std::endl
;
14 // Set up a structure that contains information necessary to
15 // create a GIOP 1.2 CDR encapsulation Codec.
16 IOP::Encoding encoding
;
17 encoding
.format
= IOP::ENCODING_CDR_ENCAPS
;
18 encoding
.major_version
= 1;
19 encoding
.minor_version
= 2;
21 // Obtain the CDR encapsulation Codec.
22 this->codec
= cf
->create_codec (encoding
);
25 ClientInterceptor::~ClientInterceptor ()
30 ClientInterceptor::name ()
32 std::cout
<< "Calling ClientInterceptor name() method" << std::endl
;
33 return CORBA::string_dup (this->myname_
);
37 ClientInterceptor::destroy ()
42 ClientInterceptor::send_poll (
43 PortableInterceptor::ClientRequestInfo_ptr ri
)
46 std::cout
<< "Calling send_poll()." << std::endl
;
51 ClientInterceptor::send_request (
52 PortableInterceptor::ClientRequestInfo_ptr ri
)
54 std::cout
<< "Calling send_request()." << std::endl
;
56 IOP::ServiceContext sc
;
57 sc
.context_id
= service_ctx_id
;
59 const CORBA::Long gid
= 9007;
60 std::cout
<< "GID: " << gid
<< std::endl
;
62 CORBA::Any gid_as_any
;
65 sc
.context_data
= *codec
->encode(gid_as_any
);
67 // Add this context to the service context list.
68 ri
->add_request_service_context (sc
, false);
72 ClientInterceptor::receive_reply (
73 PortableInterceptor::ClientRequestInfo_ptr ri
)
76 std::cout
<< "Calling receive_reply()." << std::endl
;
80 ClientInterceptor::receive_other (
81 PortableInterceptor::ClientRequestInfo_ptr ri
)
84 std::cout
<< "Calling receive_other()." << std::endl
;
88 ClientInterceptor::receive_exception (
89 PortableInterceptor::ClientRequestInfo_ptr ri
)
92 std::cout
<< "Calling receive_exception()." << std::endl
;