void SubscriptionService::doRequestSubscriptionAsync( ClientStub & clientStubOrig, const std::string & publisherName, RcfClientPtr rcfClientPtr, const SubscriptionParms & parms) { RcfClientPtr requestClientPtr( new I_RcfClient("", clientStubOrig) ); requestClientPtr->getClientStub().setTransport( clientStubOrig.releaseTransport() ); requestClientPtr->getClientStub().setAsyncDispatcher(*mpServer); // Set OOB request. boost::uint32_t subToPubPingIntervalMs = mPingIntervalMs; OobRequestSubscription msg( clientStubOrig.getRuntimeVersion(), publisherName, subToPubPingIntervalMs); ByteBuffer controlRequest; msg.encodeRequest(controlRequest); requestClientPtr->getClientStub().setOutofBandRequest(controlRequest); Future<Void> fv; fv = requestClientPtr->getClientStub().ping( RCF::AsyncTwoway( boost::bind( &SubscriptionService::doRequestSubscriptionAsync_Complete, this, fv, requestClientPtr, publisherName, rcfClientPtr, parms.mOnDisconnect, parms.mOnAsyncSubscribeCompleted ))); }
HttpsClientTransport::HttpsClientTransport(const HttpsEndpoint & httpsEndpoint) : TcpClientTransport(httpsEndpoint.getIp(), httpsEndpoint.getPort()) { std::vector<FilterPtr> wireFilters; // HTTP framing. wireFilters.push_back( FilterPtr( new HttpFrameFilter( getRemoteAddr().getIp(), getRemoteAddr().getPort()))); // SSL. ClientStub * pClientStub = getTlsClientStubPtr(); RCF_ASSERT(pClientStub); FilterPtr sslFilterPtr; #if RCF_FEATURE_SSPI==1 && RCF_FEATURE_OPENSSL==1 if (pClientStub->getSslImplementation() == Si_Schannel) { sslFilterPtr.reset( new SchannelFilter(pClientStub) ); } else { RCF_ASSERT(pClientStub->getSslImplementation() == Si_OpenSsl); sslFilterPtr.reset( new OpenSslEncryptionFilter(pClientStub) ); } #elif RCF_FEATURE_SSPI==1 sslFilterPtr.reset( new SchannelFilter(pClientStub) ); #elif RCF_FEATURE_OPENSSL==1 sslFilterPtr.reset( new OpenSslEncryptionFilter(pClientStub) ); #endif if (!sslFilterPtr) { RCF_THROW( Exception(_RcfError_SslNotSupported()) ); } wireFilters.push_back(sslFilterPtr); // HTTP CONNECT filter for passing through a proxy. wireFilters.push_back( FilterPtr( new HttpConnectFilter( getRemoteAddr().getIp(), getRemoteAddr().getPort()))); setWireFilters(wireFilters); }
boost::int32_t SubscriptionService::doRequestSubscription( ClientStub & clientStubOrig, const std::string & publisherName, boost::uint32_t subToPubPingIntervalMs, boost::uint32_t & pubToSubPingIntervalMs, bool & pingsEnabled) { I_RcfClient client("", clientStubOrig); ClientStub & clientStub = client.getClientStub(); clientStub.setTransport(clientStubOrig.releaseTransport()); pingsEnabled = true; // Set OOB request. OobRequestSubscription msg( clientStubOrig.getRuntimeVersion(), publisherName, subToPubPingIntervalMs); ByteBuffer controlRequest; msg.encodeRequest(controlRequest); clientStub.setOutofBandRequest(controlRequest); clientStub.ping(RCF::Twoway); // Get OOB response. ByteBuffer controlResponse = clientStub.getOutOfBandResponse(); clientStub.setOutofBandRequest(ByteBuffer()); clientStub.setOutofBandResponse(ByteBuffer()); msg.decodeResponse(controlResponse); boost::int32_t ret = msg.mResponseError; pubToSubPingIntervalMs = msg.mPubToSubPingIntervalMs; clientStubOrig.setTransport( client.getClientStub().releaseTransport() ); return ret; }
int getRuntimeVersionOfThisRemoteCall() { int runtimeVersion = 0; RcfSession * pRcfSession = getTlsRcfSessionPtr(); ClientStub * pClientStub = getTlsClientStubPtr(); if (pRcfSession) { runtimeVersion = pRcfSession->getRuntimeVersion(); } else if (pClientStub) { runtimeVersion = pClientStub->getRuntimeVersion(); } else { // This function must be called from within the client-side // or server-side portion of a remote call. RCF_ASSERT(0); runtimeVersion = getDefaultRuntimeVersion(); } return runtimeVersion; }
void ClientStub::assign(const ClientStub & rhs) { if (&rhs != this) { mInterfaceName = rhs.mInterfaceName; mToken = rhs.mToken; mDefaultCallingSemantics = rhs.mDefaultCallingSemantics; mProtocol = rhs.mProtocol; mMarshalingProtocol = rhs.mMarshalingProtocol; mEndpointName = rhs.mEndpointName; mObjectName = rhs.mObjectName; mRemoteCallTimeoutMs = rhs.mRemoteCallTimeoutMs; mConnectTimeoutMs = rhs.mConnectTimeoutMs; mAutoReconnect = rhs.mAutoReconnect; mConnected = false; mAutoVersioning = rhs.mAutoVersioning; mRuntimeVersion = rhs.mRuntimeVersion; mArchiveVersion = rhs.mArchiveVersion; mUseNativeWstringSerialization = rhs.mUseNativeWstringSerialization; mEnableSfPointerTracking = rhs.mEnableSfPointerTracking; mUserData = rhs.mUserData; mPingBackIntervalMs = rhs.mPingBackIntervalMs; mSignalled = false; setEndpoint(rhs.getEndpoint()); mClientProgressPtr = rhs.mClientProgressPtr; #if RCF_FEATURE_FILETRANSFER==1 mFileProgressCb = rhs.mFileProgressCb; mTransferWindowS = rhs.mTransferWindowS; #endif mHttpProxy = rhs.mHttpProxy; mHttpProxyPort = rhs.mHttpProxyPort; mTransportProtocol = rhs.mTransportProtocol; mUsername = rhs.mUsername; mPassword = rhs.mPassword; mKerberosSpn = rhs.mKerberosSpn; mEnableCompression = rhs.mEnableCompression; mCertificatePtr = rhs.mCertificatePtr; mCaCertificatePtr = rhs.mCaCertificatePtr; mCertificateValidationCb = rhs.mCertificateValidationCb; mSchannelCertificateValidation = rhs.mSchannelCertificateValidation; mOpenSslCipherSuite = rhs.mOpenSslCipherSuite; mSslImplementation = rhs.mSslImplementation; } }
void onRtfCompleted( RCF::Future<Void> fv, RcfClientPtr rtfClientPtr, ClientStub & clientStubOrig, boost::shared_ptr<std::vector<FilterPtr> > filters, boost::function0<void> onCompletion) { ClientStubPtr rtfStubPtr = rtfClientPtr->getClientStubPtr(); clientStubOrig.setTransport( rtfStubPtr->releaseTransport() ); clientStubOrig.setSubRcfClientPtr( RcfClientPtr() ); std::auto_ptr<Exception> ePtr = fv.getAsyncException(); if ( ePtr.get() ) { clientStubOrig.setAsyncException(ePtr); } else { // Get OOB response. OobRequestTransportFilters msg(clientStubOrig.getRuntimeVersion()); ByteBuffer controlResponse = rtfStubPtr->getOutOfBandResponse(); rtfStubPtr->setOutofBandRequest(ByteBuffer()); rtfStubPtr->setOutofBandResponse(ByteBuffer()); msg.decodeResponse(controlResponse); int ret = msg.mResponseError; if (ret != RcfError_Ok) { ePtr.reset( new RemoteException(Error(ret)) ); clientStubOrig.setAsyncException(ePtr); } else { for (std::size_t i=0; i<filters->size(); ++i) { (*filters)[i]->resetState(); } clientStubOrig.getTransport().setTransportFilters(*filters); } } onCompletion(); }
ClientStub::ClientStub(const ClientStub &rhs) : mToken(rhs.mToken), mDefaultCallingSemantics(rhs.mDefaultCallingSemantics), mProtocol(rhs.mProtocol), mMarshalingProtocol(DefaultMarshalingProtocol), mEndpointName(rhs.mEndpointName), mObjectName(rhs.mObjectName), mInterfaceName(rhs.mInterfaceName), mRemoteCallTimeoutMs(rhs.mRemoteCallTimeoutMs), mConnectTimeoutMs(rhs.mConnectTimeoutMs), mAutoReconnect(rhs.mAutoReconnect), mConnected(), mTries(), mAutoVersioning(rhs.mAutoVersioning), mRuntimeVersion(rhs.mRuntimeVersion), mArchiveVersion(rhs.mArchiveVersion), mUseNativeWstringSerialization(rhs.mUseNativeWstringSerialization), mEnableSfPointerTracking(rhs.mEnableSfPointerTracking), mUserData(rhs.mUserData), mAsync(), mAsyncOpType(None), mEndTimeMs(), mRetry(), mRcs(Twoway), mEncodedByteBuffer(), mEncodedByteBuffers(), mpParameters(), mPingBackIntervalMs(rhs.mPingBackIntervalMs), mPingBackTimeStamp(), mPingBackCount(), mNextTimerCallbackMs(), mNextPingBackCheckMs(), mPingBackCheckIntervalMs(), mTimerIntervalMs(), mSignalled(), mBatchMode(false), mBatchMaxMessageLength(DefaultBatchMaxMessageLimit), mBatchCount(0), mBatchMessageCount(0), mSetTransportProtocol(false), #if RCF_FEATURE_FILETRANSFER==1 mFileProgressCb(rhs.mFileProgressCb), #endif mTransferWindowS(rhs.mTransferWindowS), mCallInProgress(false), mHttpProxy(rhs.mHttpProxy), mHttpProxyPort(rhs.mHttpProxyPort), mTransportProtocol(rhs.mTransportProtocol), mUsername(rhs.mUsername), mPassword(rhs.mPassword), mKerberosSpn(rhs.mKerberosSpn), mEnableCompression(rhs.mEnableCompression), mSslImplementation(rhs.mSslImplementation) { setEndpoint( rhs.getEndpoint() ); if (rhs.mClientProgressPtr) { mClientProgressPtr.reset( new ClientProgress(*rhs.mClientProgressPtr)); } }
SubscriptionPtr SubscriptionService::onRequestSubscriptionCompleted( boost::int32_t ret, const std::string & publisherName, ClientStub & clientStub, RcfClientPtr rcfClientPtr, OnSubscriptionDisconnect onDisconnect, boost::uint32_t pubToSubPingIntervalMs, bool pingsEnabled) { if (ret != RcfError_Ok) { RCF_THROW( Exception( Error(ret) ) ); } ClientTransportAutoPtr clientTransportAutoPtr( clientStub.releaseTransport() ); ServerTransport * pTransport = NULL; ServerTransportEx * pTransportEx = NULL; pTransport = & mpServer->findTransportCompatibleWith( *clientTransportAutoPtr); pTransportEx = dynamic_cast<ServerTransportEx *>(pTransport); ServerTransportEx & serverTransportEx = * pTransportEx; SessionPtr sessionPtr = serverTransportEx.createServerSession( clientTransportAutoPtr, StubEntryPtr(new StubEntry(rcfClientPtr)), true); RCF_ASSERT( sessionPtr ); RcfSessionPtr rcfSessionPtr = sessionPtr; rcfSessionPtr->setUserData(clientStub.getUserData()); rcfSessionPtr->setPingTimestamp(); std::string publisherUrl; EndpointPtr epPtr = clientStub.getEndpoint(); if (epPtr) { publisherUrl = epPtr->asString(); } //if (!clientTransportAutoPtr->isAssociatedWithIoService()) //{ // AsioServerTransport & asioTransport = dynamic_cast<AsioServerTransport &>( // mpServer->getServerTransport()); // clientTransportAutoPtr->associateWithIoService(asioTransport.getIoService()); //} SubscriptionPtr subscriptionPtr( new Subscription( *this, clientTransportAutoPtr, rcfSessionPtr, pubToSubPingIntervalMs, publisherUrl, publisherName, onDisconnect)); rcfSessionPtr->setOnDestroyCallback( boost::bind( &Subscription::onDisconnect, SubscriptionWeakPtr(subscriptionPtr), _1)); subscriptionPtr->setWeakThisPtr(subscriptionPtr); subscriptionPtr->mPingsEnabled = pingsEnabled; Lock lock(mSubscriptionsMutex); mSubscriptions.insert(subscriptionPtr); return subscriptionPtr; }