20 #ifndef INCLUDE_RCF_RCFSERVER_HPP 21 #define INCLUDE_RCF_RCFSERVER_HPP 29 #include <RCF/Export.hpp> 31 #include <RCF/ServerTransport.hpp> 32 #include <RCF/ThreadLibrary.hpp> 34 #if RCF_FEATURE_FILETRANSFER==1 35 #include <RCF/FileTransferService.hpp> 38 #if RCF_FEATURE_PUBSUB==1 39 #include <RCF/PublishingService.hpp> 40 #include <RCF/SubscriptionService.hpp> 43 #include <RCF/ServerObjectService.hpp> 44 #include <RCF/ServerStub.hpp> 57 typedef std::function<void(RcfServer&)> StartCallback;
97 void enumerateProxyEndpoints(std::vector<std::string>& endpoints);
104 void setSupportedTransportProtocols(
105 const std::vector<TransportProtocol> & protocols);
108 const std::vector<TransportProtocol> &
109 getSupportedTransportProtocols()
const;
114 void setThreadPool(ThreadPoolPtr threadPoolPtr);
117 ThreadPoolPtr getThreadPool();
123 void waitForStopEvent();
126 void waitForStartEvent();
147 template<
typename InterfaceT,
typename ImplementationT>
150 std::reference_wrapper<ImplementationT> refWrapper(servantObj);
152 RcfClientPtr rcfClientPtr = createServerStub(
154 (ImplementationT *) 0, refWrapper);
158 InterfaceT::getInterfaceName() :
164 template<
typename InterfaceT>
165 bool unbind(
const std::string &name =
"")
167 const std::string &name_ = (name ==
"") ?
168 getInterfaceName((InterfaceT *) NULL) :
171 WriteLock writeLock(mStubMapMutex);
172 mStubMap.erase(name_);
190 void setOpenSslCipherSuite(
const std::string & cipherSuite);
193 std::string getOpenSslCipherSuite()
const;
206 getCertificateValidationCallback()
const;
209 void setEnableSchannelCertificateValidation(
const tstring & peerName);
212 tstring getEnableSchannelCertificateValidation()
const;
220 #if RCF_FEATURE_SSPI==1 221 void setSchannelEnabledProtocols(DWORD enabledProtocols);
222 DWORD getSchannelEnabledProtocols()
const;
224 void setSchannelContextRequirements(ULONG contextRequirements);
225 ULONG getSchannelContextRequirements()
const;
238 void setConnectionIdleTimeoutMs(std::uint32_t idleConnectionTimeoutMs);
241 std::uint32_t getConnectionIdleTimeoutMs();
246 void setConnectionIdleScanIntervalMs(std::uint32_t idleConnectionScanIntervalMs);
249 std::uint32_t getConnectionIdleScanIntervalMs();
255 void setHttpSessionTimeoutMs(std::uint32_t httpSessionTimeoutMs);
258 std::uint32_t getHttpSessionTimeoutMs();
261 void setHttpServerHeader(
const std::string & httpServerHeader);
264 std::string getHttpServerHeader()
const;
266 #if RCF_FEATURE_HTTP==1 271 void setHealthCheckResponse(
int statusCode, std::string statusMessage, std::string content);
272 void getHealthCheckResponse(
int& statusCode, std::string& statusMessage, std::string& content);
286 std::uint32_t getServerObjectHarvestingIntervalS()
const;
289 void setServerObjectHarvestingIntervalS(std::uint32_t harvestingIntervalS);
294 const std::string & objectKey)
296 return mServerObjectServicePtr->queryServerObject<T>(objectKey);
302 const std::string & objectKey,
303 std::uint32_t timeoutMs)
305 return mServerObjectServicePtr->getServerObject<T>(objectKey, timeoutMs);
309 void deleteServerObject(
const std::string & objectKey);
313 #if RCF_FEATURE_PUBSUB==1 324 template<
typename Interface>
328 return mPublishingServicePtr->createPublisher<Interface>(parms);
335 template<
typename Interface>
339 return mPublishingServicePtr->createPublisher<Interface>(parms);
345 template<
typename Interface,
typename T>
350 RCF_ASSERT(mStarted);
353 return mSubscriptionServicePtr->createSubscription<Interface>(servantObj, publisherEp);
359 template<
typename Interface,
typename T>
364 RCF_ASSERT(mStarted);
365 return mSubscriptionServicePtr->createSubscription<Interface>(servantObj, parms);
373 void setEnableProxyEndpoints(
bool enable);
376 bool getEnableProxyEndpoints()
const;
378 #if RCF_FEATURE_FILETRANSFER==1 386 void setUploadBandwidthLimit(std::uint32_t uploadQuotaBps);
389 std::uint32_t getUploadBandwidthLimit()
const;
392 void setDownloadBandwidthLimit(std::uint32_t downloadQuotaBps);
395 std::uint32_t getDownloadBandwidthLimit()
const;
398 void setUploadDirectory(
const Path & uploadDir);
401 Path getUploadDirectory()
const;
431 void setOnCallbackConnectionCreated(OnCallbackConnectionCreated onCallbackConnectionCreated);
432 OnCallbackConnectionCreated getOnCallbackConnectionCreated();
443 getServerTransportService();
446 getServerTransportPtr();
451 ServicePtr servicePtr);
454 ServicePtr servicePtr);
459 getPingBackServicePtr();
461 FileTransferServicePtr
462 getFileTransferServicePtr();
464 SessionTimeoutServicePtr
465 getSessionTimeoutServicePtr();
468 getPublishingServicePtr();
470 SubscriptionServicePtr
471 getSubscriptionServicePtr();
473 FilterServicePtr getFilterServicePtr();
475 bool addServerTransport(
478 bool removeServerTransport(
486 void setStartCallback(
const StartCallback &startCallback);
489 void invokeStartCallback();
493 const std::string &name,
494 RcfClientPtr rcfClientPtr);
500 SessionPtr createSession();
501 void onReadCompleted(SessionPtr sessionPtr);
502 void onWriteCompleted(SessionPtr sessionPtr);
511 template<
typename Iter>
512 void enumerateSessions(
const Iter & iter)
514 for (std::size_t i=0; i<mServerTransports.size(); ++i)
516 mServerTransports[i]->enumerateSessions(iter);
524 ReadWriteMutex mStubMapMutex;
525 typedef std::map<std::string, RcfClientPtr> StubMap;
529 typedef std::function<void(const JsonRpcRequest &, JsonRpcResponse &)> JsonRpcMethod;
530 typedef std::map<std::string, JsonRpcMethod> JsonRpcMethods;
531 JsonRpcMethods mJsonRpcMethods;
541 std::vector<ServerTransportPtr> mServerTransports;
542 std::vector<ServicePtr> mServices;
543 FilterServicePtr mFilterServicePtr;
544 PingBackServicePtr mPingBackServicePtr;
545 FileTransferServicePtr mFileTransferServicePtr;
546 SessionTimeoutServicePtr mSessionTimeoutServicePtr;
547 PublishingServicePtr mPublishingServicePtr;
548 SubscriptionServicePtr mSubscriptionServicePtr;
549 CallbackConnectionServicePtr mCallbackConnectionServicePtr;
550 ProxyEndpointServicePtr mProxyEndpointServicePtr;
551 ServerObjectServicePtr mServerObjectServicePtr;
553 void startService(ServicePtr servicePtr)
const;
554 void stopService(ServicePtr servicePtr)
const;
555 void resolveServiceThreadPools(ServicePtr servicePtr)
const;
557 friend class AsioNetworkSession;
558 FilterPtr createFilter(
int filterId);
561 StartCallback mStartCallback;
562 Condition mStartEvent;
563 Condition mStopEvent;
565 Mutex mStartStopMutex;
569 ThreadPoolPtr mThreadPoolPtr;
574 friend class MethodInvocationRequest;
577 std::uint32_t mRuntimeVersion;
578 std::uint32_t mArchiveVersion;
583 #if RCF_FEATURE_FILETRANSFER==1 586 Path getUploadPath(
const std::string & uploadId);
593 Path mFileUploadDirectory;
595 std::uint32_t mFileUploadQuota;
598 std::uint32_t mFileDownloadQuota;
601 friend class FileTransferService;
607 mutable ReadWriteMutex mPropertiesMutex;
609 std::vector<TransportProtocol> mSupportedProtocols;
611 std::string mOpenSslCipherSuite;
615 tstring mSchannelCertificateValidation;
619 std::uint32_t mSessionTimeoutMs;
620 std::uint32_t mSessionHarvestingIntervalMs;
622 std::uint32_t mHttpSessionTimeoutMs;
624 std::string mHttpServerHeader;
626 std::uint32_t mHttpHealthCheckStatus = 0;
627 std::string mHttpHealthCheckStatusMessage;
628 std::string mHttpHealthCheckContent;
630 OnCallbackConnectionCreated mOnCallbackConnectionCreated;
632 #if RCF_FEATURE_SSPI==1 633 DWORD mSchannelEnabledProtocols = 0;
634 ULONG mSchannelContextRequirements = 0;
642 std::uint32_t mServerObjectHarvestingIntervalS;
644 friend class HttpSessionFilter;
646 HttpSessionPtr attachHttpSession(
const std::string & httpSessionId,
bool allowCreate, ExceptionPtr & ePtr);
647 void detachHttpSession(HttpSessionPtr httpSessionPtr);
649 friend class ServerObjectService;
650 void harvestHttpSessions();
652 #if RCF_FEATURE_HTTP==1 653 Mutex mHttpSessionMapMutex;
654 std::map<std::string, HttpSessionPtr> mHttpSessionMap;
667 bool mEnableProxyEndpoints =
false;
673 #endif // ! INCLUDE_RCF_RCFSERVER_HPP 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.
std::function< void(RcfSession &, FileDownloadInfo &)> DownloadProgressCallback
Describes user-provided callback functions for server-side monitoring of a file download.
Definition: RcfFwd.hpp:134
std::shared_ptr< Subscription > createSubscription(T &servantObj, const SubscriptionParms &parms)
Creates a subscription to a remote RCF publisher.
Definition: RcfServer.hpp:360
Represents a server side session, associated with a client connection.
Definition: RcfSession.hpp:64
std::shared_ptr< Certificate > CertificatePtr
Reference counted wrapper for RCF::Certificate.
Definition: RcfFwd.hpp:108
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:43
std::shared_ptr< T > queryServerObject(const std::string &objectKey)
Queries for a server object under the given key. Returns an empty std::shared_ptr if no object is fou...
Definition: RcfServer.hpp:293
Base class for all client transports.
Definition: ClientTransport.hpp:74
Base class for all server transports.
Definition: ServerTransport.hpp:121
void setPublisherEndpoint(const Endpoint &publisherEp)
Sets the network endpoint of the publishing server.
BandwidthQuotaCallback DownloadBandwidthQuotaCallback
Describes user-provided callback functions for assigning custom bandwidth quotas to a RcfSession...
Definition: RcfFwd.hpp:146
std::function< bool(Certificate *)> CertificateValidationCallback
Describes user-provided callback functions for validating a certificate.
Definition: RcfFwd.hpp:114
std::shared_ptr< Publisher< Interface > > createPublisher()
Creates a publisher instance for the given RCF interface.
Definition: RcfServer.hpp:325
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.
std::shared_ptr< T > getServerObject(const std::string &objectKey, std::uint32_t timeoutMs)
Queries or creates a server object under the given key. If creating the object, the timeout value is ...
Definition: RcfServer.hpp:301
BandwidthQuotaCallback UploadBandwidthQuotaCallback
Describes user-provided callback functions for assigning custom bandwidth quotas to a RcfSession...
Definition: RcfFwd.hpp:143
SslImplementation
Describes which SSL implementation to use.
Definition: Enums.hpp:84
ServerBindingPtr bind(ImplementationT &servantObj, const std::string &name="")
Creates a servant binding, exposing the servant object to remote calls through the RCF interface Inte...
Definition: RcfServer.hpp:148
std::shared_ptr< ServerBinding > ServerBindingPtr
Reference counted wrapper for RCF::ServerBinding.
Definition: RcfFwd.hpp:248
std::shared_ptr< Publisher< Interface > > createPublisher(const PublisherParms &parms)
Creates a publisher instance for the given RCF interface.
Definition: RcfServer.hpp:336
Provides RCF server-side functionality.
Definition: RcfServer.hpp:53
bool unbind(const std::string &name="")
Removes a servant binding from the RcfServer.
Definition: RcfServer.hpp:165
Base class for all network endpoint types.
Definition: Endpoint.hpp:40
std::function< void(RcfSession &, FileUploadInfo &)> UploadProgressCallback
Describes user-provided callback functions for server-side monitoring of a file upload.
Definition: RcfFwd.hpp:137
Base class for IP-based server transports. Provides IP-related functionality.
Definition: IpServerTransport.hpp:36
General configuration of a subscription.
Definition: SubscriptionService.hpp:95
Definition: AmiIoHandler.hpp:23
TransportType
Describes the transport types used by a RCF connection.
Definition: Enums.hpp:33
Represents a proxy endpoint.
Definition: ProxyEndpoint.hpp:45
General configuration of a publisher.
Definition: PublishingService.hpp:38
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::shared_ptr< ServerTransport > ServerTransportPtr
Unique pointer wrapper for RCF::ServerTransport.
Definition: RcfFwd.hpp:46
RCF_EXPORT bool init(RcfConfigT *=nullptr)
Reference-counted initialization of RCF library. May be called multiple times (see deinit())...
std::shared_ptr< Subscription > createSubscription(T &servantObj, const RCF::Endpoint &publisherEp)
Creates a subscription to a remote RCF publisher.
Definition: RcfServer.hpp:346