20 #ifndef INCLUDE_RCF_CLIENTSTUB_HPP 21 #define INCLUDE_RCF_CLIENTSTUB_HPP 28 #include <RCF/ClientTransport.hpp> 30 #include <RCF/Export.hpp> 32 #include <RCF/MethodInvocation.hpp> 33 #include <RCF/SerializationProtocol_Base.hpp> 35 #include <RCF/RecursionLimiter.hpp> 36 #include <RCF/SerializationProtocol.hpp> 38 #include <RCF/ThreadLibrary.hpp> 40 #if RCF_FEATURE_FILETRANSFER==1 41 #include <RCF/FileDownload.hpp> 42 #include <RCF/FileUpload.hpp> 63 HttpCookie(
const std::string& name,
const std::string& value);
68 class RCF_EXPORT CurrentClientStubSentry
71 CurrentClientStubSentry(
ClientStub & clientStub);
72 CurrentClientStubSentry(
ClientStub * pClientStub);
73 ~CurrentClientStubSentry();
83 public ClientTransportCallback,
84 public std::enable_shared_from_this<ClientStub>
89 ClientStub(
const std::string & interfaceName,
const std::string &serverBindingName);
96 void init(
const std::string & interfaceName,
const std::string & serverBindingName);
101 void setInterfaceName(
const std::string & interfaceName);
113 void setServerEndpoint(
const Endpoint &endpoint);
154 void setAutoReconnect(
bool autoReconnect);
157 bool getAutoReconnect()
const;
163 void setConnectTimeoutMs(
unsigned int connectTimeoutMs);
166 unsigned int getConnectTimeoutMs()
const;
171 void instantiateTransport();
174 void setEndpoint(
const Endpoint &endpoint);
198 void setUserName(
const tstring & username);
201 tstring getUserName()
const;
206 void setPassword(
const tstring & password);
209 tstring getPassword()
const;
214 void setKerberosSpn(
const tstring & kerberosSpn);
217 tstring getKerberosSpn()
const;
222 void setEnableCompression(
bool enableCompression);
225 bool getEnableCompression()
const;
242 const std::string & getInterfaceName();
257 void setEnableSfPointerTracking(
bool enable);
260 bool getEnableSfPointerTracking()
const;
267 void setAutoVersioning(
bool autoVersioning);
270 bool getAutoVersioning()
const;
295 void setPingBackIntervalMs(
int pingBackIntervalMs);
298 int getPingBackIntervalMs();
303 void setRemoteCallTimeoutMs(
unsigned int remoteCallTimeoutMs);
306 unsigned int getRemoteCallTimeoutMs()
const;
310 void setRemoteCallProgressCallback(
312 std::uint32_t callbackIntervalMs);
318 const std::string & getServerBindingName()
const;
321 void setServerBindingName(
const std::string &bindingName);
324 #if RCF_FEATURE_FILETRANSFER==1 334 const std::string& downloadId,
335 const Path& downloadPath,
340 std::string& uploadId,
341 const Path& uploadPath,
355 void setRequestUserData(
const std::string & userData);
358 std::string getRequestUserData();
361 void setResponseUserData(
const std::string & userData);
364 std::string getResponseUserData();
372 void setOutofBandRequest(
ByteBuffer requestBuffer);
378 void setOutofBandResponse(
ByteBuffer responseBuffer);
387 void setHttpProxy(
const std::string & httpProxy);
390 std::string getHttpProxy()
const;
393 void setHttpProxyPort(
int httpProxyPort);
396 int getHttpProxyPort()
const;
399 void setHttpProxyUserName(
const tstring & proxyUsername);
402 tstring getHttpProxyUserName()
const;
405 void setHttpProxyPassword(
const tstring & proxyPassword);
408 tstring getHttpProxyPassword()
const;
411 void setHttpProxyRealm(
const tstring & proxyRealm);
414 tstring getHttpProxyRealm()
const;
421 void setHttpCookies(
const std::vector<HttpCookie> & cookies);
424 std::vector<HttpCookie> getHttpCookies()
const;
427 void clearHttpCookies();
436 void setHttpUrlParameterString(
const std::string & urlParameterString);
439 std::string getHttpUrlParameterString()
const;
449 #if RCF_FEATURE_HTTP==1 451 void getHttpFrameInfo(
452 std::string& responseLine,
453 std::vector< std::pair<std::string, std::string> >& headers);
457 void setHttpConnectionCloseHeader(
bool connectionClose);
460 bool getHttpConnectionCloseHeader()
const;
482 void setOpenSslCipherSuite(
const std::string & cipherSuite);
485 std::string getOpenSslCipherSuite()
const;
488 void setEnableSchannelCertificateValidation(
const tstring & peerName);
491 tstring getEnableSchannelCertificateValidation()
const;
500 void setTlsSniName(
const tstring & serverName);
503 tstring getTlsSniName()
const;
511 #if RCF_FEATURE_SSPI==1 513 void setSchannelEnabledProtocols(DWORD enabledProtocols);
514 DWORD getSchannelEnabledProtocols()
const;
516 void setSchannelContextRequirements(ULONG contextRequirements);
517 ULONG getSchannelContextRequirements()
const;
521 PCtxtHandle getTransportSecurityContext()
const;
525 PCtxtHandle getTransportProtocolSecurityContext()
const;
531 void setWindowsImpersonationToken(HANDLE hToken);
535 HANDLE getWindowsImpersonationToken()
const;
547 void enableBatching();
550 void disableBatching(
bool flush =
true);
553 void flushBatch(
unsigned int timeoutMs = 0);
556 void setMaxBatchMessageLength(std::uint32_t maxBatchMessageLength);
559 std::uint32_t getMaxBatchMessageLength();
562 std::uint32_t getBatchesSent();
565 std::uint32_t getMessagesInCurrentBatch();
576 void connectAsync(std::function<
void()> onCompletion);
582 void waitForReady(std::uint32_t timeoutMs = 0);
588 bool hasAsyncException();
591 std::unique_ptr<Exception> getAsyncException();
596 void wait(std::function<
void()> onCompletion, std::uint32_t timeoutMs);
598 void setTries(std::size_t tries);
599 std::size_t getTries()
const;
601 #if RCF_FEATURE_FILETRANSFER==1 610 const std::string & whichFile,
611 std::string & uploadId,
612 std::uint32_t chunkSize,
613 std::uint32_t transferRateBps,
614 std::uint32_t sessionLocalId);
617 const FileManifest & whichFile,
618 std::string & uploadId,
619 std::uint32_t chunkSize,
620 std::uint32_t transferRateBps,
621 std::uint32_t sessionLocalId);
624 const Path& downloadToPath,
625 FileManifest & manifest,
626 std::uint32_t chunkSize,
627 std::uint32_t transferRateBps,
628 std::uint32_t sessionLocalId,
629 const std::string & downloadId,
630 std::uint64_t startPos = 0,
631 std::uint64_t endPos = -1);
633 std::uint32_t addUploadStream(FileUpload fileStream);
634 void processUploadStreams();
636 std::uint32_t addDownloadStream(FileDownload fileStream);
639 void setTransferWindowS(std::uint32_t transferWindowS);
640 std::uint32_t getTransferWindowS();
647 const CallOptions & callOptions,
654 std::size_t getPingBackCount();
655 std::uint32_t getPingBackTimeStamp();
657 void clearParameters();
659 SerializationProtocolIn & getSpIn();
660 SerializationProtocolOut & getSpOut();
662 void setAsync(
bool async);
665 void setAsyncException(std::unique_ptr<Exception>);
667 std::uint32_t generatePollingTimeout(std::uint32_t timeoutMs);
668 void onPollingTimeout(
bool eventBased =
false);
671 void setSubRcfClientPtr(RcfClientPtr clientStubPtr);
672 RcfClientPtr getSubRcfClientPtr();
674 void setEnableNativeWstringSerialization(
bool enable);
675 bool getEnableNativeWstringSerialization()
const;
677 friend class CallOptions;
681 friend class FutureConverterBase;
682 friend class FutureImplBase;
701 friend class AllocateClientParameters;
720 friend class ClientParameters;
741 void onConnectCompleted(
742 bool alreadyConnected =
false);
744 void setupTransportProtocol();
745 void onSetupTransportProtocolCompleted();
749 void onSendCompleted();
751 void onReceiveCompleted();
753 void onTimerExpired();
756 const std::exception &e);
758 void setAsyncCallback(
759 std::function<
void()> callback);
764 void scheduleAmiNotification();
766 void createFilterSequence(std::vector<FilterPtr> & filters);
768 void setConnected(
bool connected);
770 virtual bool isClientStub()
const;
778 void requestTransportFilters(
const std::vector<FilterPtr> &filters);
779 void requestTransportFilters(FilterPtr filterPtr);
780 void requestTransportFilters();
782 void clearTransportFilters();
785 void requestTransportFiltersAsync(
786 const std::vector<FilterPtr> & filters,
787 std::function<
void()> onCompletion);
789 void requestTransportFiltersAsync(
791 std::function<
void()> onCompletion);
793 void setMessageFilters(
const std::vector<FilterPtr> &filters);
794 void setMessageFilters();
795 void setMessageFilters(FilterPtr filterPtr);
797 const std::vector<FilterPtr> &getMessageFilters();
799 std::vector<char> & getRetValVec();
802 void setupProxiedConnection(
const std::string& proxyEndpointName);
805 std::string mProxyEndpointName;
811 std::string mEndpointName;
812 std::string mServerBindingName;
813 std::string mInterfaceName;
815 unsigned int mRemoteCallTimeoutMs;
816 unsigned int mConnectTimeoutMs;
824 std::vector<FilterPtr> mMessageFilters;
827 unsigned int mProgressCallbackIntervalMs = 0;
830 bool mAutoVersioning;
831 std::uint32_t mRuntimeVersion;
832 std::uint32_t mArchiveVersion;
834 bool mEnableSfPointerTracking;
835 bool mEnableNativeWstringSerialization =
false;
837 std::vector<I_Future *> mFutures;
839 MethodInvocationRequest mRequest;
840 SerializationProtocolIn mIn;
841 SerializationProtocolOut mOut;
844 AsyncOpType mAsyncOpType;
845 std::function<void()> mAsyncCallback;
846 std::unique_ptr<Exception> mAsyncException;
847 unsigned int mEndTimeMs;
851 std::vector<ByteBuffer> mEncodedByteBuffers;
853 std::vector<char> mRetValVec;
854 std::vector<char> mParametersVec;
855 I_Parameters * mpParameters;
857 std::uint32_t mPingBackIntervalMs;
858 std::uint32_t mPingBackTimeStamp;
859 std::size_t mPingBackCount;
861 std::uint32_t mNextTimerCallbackMs;
862 std::uint32_t mNextPingBackCheckMs;
863 std::uint32_t mPingBackCheckIntervalMs;
865 MutexPtr mSignalledMutexPtr;
866 ConditionPtr mSignalledConditionPtr;
867 LockPtr mSignalledLockPtr;
871 Mutex mSubRcfClientMutex;
872 RcfClientPtr mSubRcfClientPtr;
875 ReallocBufferPtr mBatchBufferPtr;
876 ReallocBuffer mBatchBufferTemp;
877 std::uint32_t mBatchMaxMessageLength;
878 std::uint32_t mBatchCount;
879 std::uint32_t mBatchMessageCount;
882 bool mSetTransportProtocol;
885 #if RCF_FEATURE_FILETRANSFER==1 888 std::vector<FileUpload> mUploadStreams;
889 std::vector<FileDownload> mDownloadStreams;
892 std::uint32_t mTransferWindowS;
894 RecursionState<int, int> mRecursionState;
898 std::string mCurrentCallMethodName;
899 std::string mCurrentCallDesc;
900 bool mCallInProgress;
904 std::unique_ptr<HANDLE> mWindowsImpersonationToken;
908 std::string mHttpProxy;
910 tstring mHttpProxyRealm;
911 std::map<std::string, HttpCookie> mHttpCookies;
915 tstring mHttpProxyUsername;
916 tstring mHttpProxyPassword;
917 std::string mHttpUrlParameterString;
919 tstring mKerberosSpn;
920 bool mEnableCompression;
926 tstring mSchannelCertificateValidation;
928 std::string mOpenSslCipherSuite;
934 #if RCF_FEATURE_SSPI==1 935 DWORD mSchannelEnabledProtocols = 0;
936 ULONG mSchannelContextRequirements = 0;
939 bool mHttpConnectionClose =
false;
941 friend class HttpFrameFilter;
942 std::map<std::string, HttpCookie> & getCookieMap();
945 void requestTransportFilters_Legacy(
const std::vector<FilterPtr> &filters);
947 void requestTransportFiltersAsync_Legacy(
948 const std::vector<FilterPtr> &filters,
949 std::function<
void()> onCompletion);
952 class RCF_EXPORT CallOptions
957 CallOptions(
RemoteCallMode rcs,
const std::function<
void()> & callback);
958 CallOptions(std::function<
void()> callback);
965 std::function<void()> mCallback;
968 class RCF_EXPORT AsyncTwoway :
public CallOptions
971 AsyncTwoway(
const std::function<
void()> & callback);
974 class RCF_EXPORT AsyncOneway :
public CallOptions
977 AsyncOneway(
const std::function<
void()> & callback);
980 class RestoreClientTransportGuard
985 ~RestoreClientTransportGuard();
994 #endif // ! INCLUDE_RCF_CLIENTSTUB_HPP SspiMessageProtection
Definition: Enums.hpp:206
RCF_FILESYSTEM_NS::path Path
Typedef for standard C++ path type.
Definition: FileSystem.hpp:31
RCF_EXPORT std::uint32_t getArchiveVersion()
Gets the RCF archive version number.
Base class of all RcfClient<> templates.
Definition: RcfClient.hpp:44
std::function< void(const RemoteCallProgressInfo &, RemoteCallAction &)> RemoteCallProgressCallback
Describes a user-provided callback function to be called periodically on the client side...
Definition: RcfFwd.hpp:83
Client side options for downloading and uploading files.
Definition: FileStream.hpp:370
Controls the client side of a RCF connection.
Definition: ClientStub.hpp:82
std::shared_ptr< Endpoint > EndpointPtr
Reference counted wrapper for RCF::Endpoint.
Definition: RcfFwd.hpp:117
std::shared_ptr< Certificate > CertificatePtr
Reference counted wrapper for RCF::Certificate.
Definition: RcfFwd.hpp:108
SerializationProtocol
Describes which serialization implementation to use when serializing data structures for a remote cal...
Definition: Enums.hpp:166
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:43
Base class for all client transports.
Definition: ClientTransport.hpp:74
std::function< bool(Certificate *)> CertificateValidationCallback
Describes user-provided callback functions for validating a certificate.
Definition: RcfFwd.hpp:114
RemoteCallMode
Remote call mode.
Definition: Enums.hpp:140
Provides the ability for remote calls to be executed asynchronously.
Definition: Future.hpp:50
Base class for all RCF exceptions.
Definition: Exception.hpp:67
std::function< void(const FileTransferProgress &, RemoteCallAction &)> FileProgressCallback
Describes user-provided callback functions for client-side monitoring of a file transfer (download or...
Definition: RcfFwd.hpp:131
RCF_EXPORT void setArchiveVersion(std::uint32_t version)
Sets the RCF archive version number. Applies to all RCF clients and servers within the current proces...
std::shared_ptr< HttpMessageVerifier > HttpMessageVerifierPtr
Reference counted wrapper for RCF::HttpMessageVerifier.
Definition: HttpFrameFilter.hpp:60
RCF_EXPORT std::uint32_t getRuntimeVersion()
Gets the RCF runtime version number.
SslImplementation
Describes which SSL implementation to use.
Definition: Enums.hpp:84
Utility class used by RCF to determine whether a remote call should be performed synchronously or asy...
Definition: Future.hpp:34
Base class for all network endpoint types.
Definition: Endpoint.hpp:40
Base class for IP-based client transports. Provides IP-related functionality.
Definition: IpClientTransport.hpp:27
Represents an HTTP cookie, with a name and value.
Definition: ClientStub.hpp:59
Definition: ByteBuffer.hpp:39
TransportProtocol
Describes the transport protocols used by a RCF connection. Transport protocols are layered on top of...
Definition: Enums.hpp:62
Definition: AmiIoHandler.hpp:23
TransportType
Describes the transport types used by a RCF connection.
Definition: Enums.hpp:33
RCF_EXPORT void setRuntimeVersion(std::uint32_t version)
Sets the RCF runtime version number. Applies to all RCF clients and servers within the current proces...
std::function< void(const std::string &statusLine, const HttpHeaderList &headerList)> HttpRedirectHandler
Describes a user-provided function for handling HTTP redirect responses when connecting to a HTTP/HTT...
Definition: RcfFwd.hpp:333
RCF_EXPORT bool init(RcfConfigT *=nullptr)
Reference-counted initialization of RCF library. May be called multiple times (see deinit())...
Describes progress of a file download or upload.
Definition: FileStream.hpp:265