diff options
author | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2008-10-21 20:47:43 +0000 |
---|---|---|
committer | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2008-10-21 20:47:43 +0000 |
commit | d2911d5b9eb897d3da7d458ebf5ba8b998bc7763 (patch) | |
tree | 3158327d3787df5b439329fac177f20a12857c62 /TAO/DevGuideExamples/PortableInterceptors/PICurrent/ClientInterceptor.cpp | |
parent | f8ea2bc5a4d98525f6f290d8272663e46aa1de74 (diff) | |
download | ATCD-d2911d5b9eb897d3da7d458ebf5ba8b998bc7763.tar.gz |
Tue Oct 21 19:10:21 UTC 2008 Abdullah Sowayan <abdullah.sowayan@lmco.com>
Diffstat (limited to 'TAO/DevGuideExamples/PortableInterceptors/PICurrent/ClientInterceptor.cpp')
-rw-r--r-- | TAO/DevGuideExamples/PortableInterceptors/PICurrent/ClientInterceptor.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/TAO/DevGuideExamples/PortableInterceptors/PICurrent/ClientInterceptor.cpp b/TAO/DevGuideExamples/PortableInterceptors/PICurrent/ClientInterceptor.cpp new file mode 100644 index 00000000000..52454103c10 --- /dev/null +++ b/TAO/DevGuideExamples/PortableInterceptors/PICurrent/ClientInterceptor.cpp @@ -0,0 +1,109 @@ +#include "ClientInterceptor.h" +#include "tao/OctetSeqC.h" +#include "tao/PI/ClientRequestInfo.h" +#include "MessengerC.h" +#include "ace/OS_NS_string.h" +#include <iostream> + +const CORBA::ULong service_ctx_id = 0xdeed; + +ClientInterceptor:: +ClientInterceptor (Messenger_var theMessenger, + PortableInterceptor::Current_ptr thePic, + PortableInterceptor::SlotId theSlot) + : myname_ ("Client_Authentication_Interceptor") +{ + std::cout << "Calling ClientInterceptor constructor." << std::endl; + this->messenger = theMessenger; + this->pic = thePic; + this->slot = theSlot; +} + +ClientInterceptor::~ClientInterceptor (void) +{ +} + +char * +ClientInterceptor::name () +{ + std::cout << "Calling ClientInterceptor name() method" << std::endl; + return CORBA::string_dup (this->myname_); +} + +void +ClientInterceptor::destroy () +{ +} + +void +ClientInterceptor::send_poll (PortableInterceptor::ClientRequestInfo_ptr ri) +{ + ACE_UNUSED_ARG(ri); + std::cout << "Calling send_poll()." << std::endl; +} + + +void +ClientInterceptor::send_request (PortableInterceptor::ClientRequestInfo_ptr ri) +{ + std::cout << "Calling send_request()." << std::endl; + + IOP::ServiceContext sc; + sc.context_id = service_ctx_id; + + const char user_name[] = "Ron Klein"; + std::cout << "User's Name: " << user_name << std::endl; + CORBA::ULong string_len = sizeof (user_name) + 1; + CORBA::Octet *buf = 0; + buf = new CORBA::Octet [string_len]; + + ACE_OS::strcpy (reinterpret_cast<char*> (buf), user_name); + + sc.context_data.replace (string_len, string_len, buf, 1); + + // recursive call setup + CORBA::Any *recurse = ri->get_slot(slot); + CORBA::Boolean x; + *recurse >>= CORBA::Any::to_boolean(x); + + CORBA::Any flag; + if (x == 0) + { + x = 1; + flag <<= CORBA::Any::from_boolean(x); + + pic->set_slot(slot, flag); + + // get server time + std::cout << "Server Time = " << messenger->get_time() << std::endl; + } + // Add this context to the service context list. + ri->add_request_service_context (sc, 0); + + // reset recursion test + x = 0; + flag <<= CORBA::Any::from_boolean(x); + pic->set_slot(slot,flag); + +} + +void +ClientInterceptor::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri) +{ + ACE_UNUSED_ARG(ri); + std::cout << "Calling receive_reply()." << std::endl; +} + +void +ClientInterceptor::receive_other (PortableInterceptor::ClientRequestInfo_ptr ri) +{ + ACE_UNUSED_ARG(ri); + std::cout << "Calling receive_other()." << std::endl; +} + +void +ClientInterceptor::receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri) +{ + ACE_UNUSED_ARG(ri); + std::cout << "Calling receive_exception()." << std::endl; +} |