21 #ifndef INCLUDE_RCF_RCFSERVER_HPP 22 #define INCLUDE_RCF_RCFSERVER_HPP 30 #include <RCF/Export.hpp> 32 #include <RCF/ServerTransport.hpp> 33 #include <RCF/ThreadLibrary.hpp> 35 #if RCF_FEATURE_FILETRANSFER==1 36 #include <RCF/FileTransferService.hpp> 39 #if RCF_FEATURE_PUBSUB==1 40 #include <RCF/PublishingService.hpp> 41 #include <RCF/SubscriptionService.hpp> 44 #include <RCF/ServerObjectService.hpp> 45 #include <RCF/ServerStub.hpp> 58 typedef std::function<void(RcfServer&)> StartCallback;
98 void enumerateProxyEndpoints(std::vector<std::string>& endpoints);
105 void setSupportedTransportProtocols(
106 const std::vector<TransportProtocol> & protocols);
109 const std::vector<TransportProtocol> &
110 getSupportedTransportProtocols()
const;
115 void setThreadPool(ThreadPoolPtr threadPoolPtr);
118 ThreadPoolPtr getThreadPool();
124 void waitForStopEvent();
127 void waitForStartEvent();
148 template<
typename InterfaceT,
typename ImplementationT>
151 std::reference_wrapper<ImplementationT> refWrapper(servantObj);
153 RcfClientPtr rcfClientPtr = createServerStub(
155 (ImplementationT *) 0, refWrapper);
159 InterfaceT::getInterfaceName() :
165 template<
typename InterfaceT>
166 bool unbind(
const std::string &name =
"")
168 const std::string &name_ = (name ==
"") ?
169 getInterfaceName((InterfaceT *) NULL) :
172 WriteLock writeLock(mStubMapMutex);
173 mStubMap.erase(name_);
191 void setOpenSslCipherSuite(
const std::string & cipherSuite);
194 std::string getOpenSslCipherSuite()
const;
207 getCertificateValidationCallback()
const;
210 void setEnableSchannelCertificateValidation(
const tstring & peerName);
213 tstring getEnableSchannelCertificateValidation()
const;
221 #if RCF_FEATURE_SSPI==1 222 void setSchannelEnabledProtocols(DWORD enabledProtocols);
223 DWORD getSchannelEnabledProtocols()
const;
225 void setSchannelContextRequirements(ULONG contextRequirements);
226 ULONG getSchannelContextRequirements()
const;
239 void setConnectionIdleTimeoutMs(std::uint32_t idleConnectionTimeoutMs);
242 std::uint32_t getConnectionIdleTimeoutMs();
247 void setConnectionIdleScanIntervalMs(std::uint32_t idleConnectionScanIntervalMs);
250 std::uint32_t getConnectionIdleScanIntervalMs();
256 void setHttpSessionTimeoutMs(std::uint32_t httpSessionTimeoutMs);
259 std::uint32_t getHttpSessionTimeoutMs();
273 std::uint32_t getServerObjectHarvestingIntervalS()
const;
276 void setServerObjectHarvestingIntervalS(std::uint32_t harvestingIntervalS);
281 const std::string & objectKey)
283 return mServerObjectServicePtr->queryServerObject<T>(objectKey);
289 const std::string & objectKey,
290 std::uint32_t timeoutMs)
292 return mServerObjectServicePtr->getServerObject<T>(objectKey, timeoutMs);
296 void deleteServerObject(
const std::string & objectKey);
300 #if RCF_FEATURE_PUBSUB==1 311 template<
typename Interface>
315 return mPublishingServicePtr->createPublisher<Interface>(parms);
322 template<
typename Interface>
326 return mPublishingServicePtr->createPublisher<Interface>(parms);
332 template<
typename Interface,
typename T>
337 RCF_ASSERT(mStarted);
340 return mSubscriptionServicePtr->createSubscription<Interface>(servantObj, publisherEp);
346 template<
typename Interface,
typename T>
351 RCF_ASSERT(mStarted);
352 return mSubscriptionServicePtr->createSubscription<Interface>(servantObj, parms);
360 void setEnableProxyEndpoints(
bool enable);
363 bool getEnableProxyEndpoints()
const;
365 #if RCF_FEATURE_FILETRANSFER==1 373 void setUploadBandwidthLimit(std::uint32_t uploadQuotaBps);
376 std::uint32_t getUploadBandwidthLimit()
const;
379 void setDownloadBandwidthLimit(std::uint32_t downloadQuotaBps);
382 std::uint32_t getDownloadBandwidthLimit()
const;
385 void setUploadDirectory(
const Path & uploadDir);
388 Path getUploadDirectory()
const;
418 void setOnCallbackConnectionCreated(OnCallbackConnectionCreated onCallbackConnectionCreated);
419 OnCallbackConnectionCreated getOnCallbackConnectionCreated();
430 getServerTransportService();
433 getServerTransportPtr();
438 ServicePtr servicePtr);
441 ServicePtr servicePtr);
446 getPingBackServicePtr();
448 FileTransferServicePtr
449 getFileTransferServicePtr();
451 SessionTimeoutServicePtr
452 getSessionTimeoutServicePtr();
455 getPublishingServicePtr();
457 SubscriptionServicePtr
458 getSubscriptionServicePtr();
460 FilterServicePtr getFilterServicePtr();
462 bool addServerTransport(
465 bool removeServerTransport(
473 void setStartCallback(
const StartCallback &startCallback);
476 void invokeStartCallback();
480 const std::string &name,
481 RcfClientPtr rcfClientPtr);
487 SessionPtr createSession();
488 void onReadCompleted(SessionPtr sessionPtr);
489 void onWriteCompleted(SessionPtr sessionPtr);
498 template<
typename Iter>
499 void enumerateSessions(
const Iter & iter)
501 for (std::size_t i=0; i<mServerTransports.size(); ++i)
503 mServerTransports[i]->enumerateSessions(iter);
511 ReadWriteMutex mStubMapMutex;
512 typedef std::map<std::string, RcfClientPtr> StubMap;
516 typedef std::function<void(const JsonRpcRequest &, JsonRpcResponse &)> JsonRpcMethod;
517 typedef std::map<std::string, JsonRpcMethod> JsonRpcMethods;
518 JsonRpcMethods mJsonRpcMethods;
528 std::vector<ServerTransportPtr> mServerTransports;
529 std::vector<ServicePtr> mServices;
530 FilterServicePtr mFilterServicePtr;
531 PingBackServicePtr mPingBackServicePtr;
532 FileTransferServicePtr mFileTransferServicePtr;
533 SessionTimeoutServicePtr mSessionTimeoutServicePtr;
534 PublishingServicePtr mPublishingServicePtr;
535 SubscriptionServicePtr mSubscriptionServicePtr;
536 CallbackConnectionServicePtr mCallbackConnectionServicePtr;
537 ProxyEndpointServicePtr mProxyEndpointServicePtr;
538 ServerObjectServicePtr mServerObjectServicePtr;
540 void startService(ServicePtr servicePtr)
const;
541 void stopService(ServicePtr servicePtr)
const;
542 void resolveServiceThreadPools(ServicePtr servicePtr)
const;
544 friend class AsioNetworkSession;
545 FilterPtr createFilter(
int filterId);
548 StartCallback mStartCallback;
549 Condition mStartEvent;
550 Condition mStopEvent;
552 Mutex mStartStopMutex;
556 ThreadPoolPtr mThreadPoolPtr;
561 friend class MethodInvocationRequest;
564 std::uint32_t mRuntimeVersion;
565 std::uint32_t mArchiveVersion;
570 #if RCF_FEATURE_FILETRANSFER==1 573 Path getUploadPath(
const std::string & uploadId);
580 Path mFileUploadDirectory;
582 std::uint32_t mFileUploadQuota;
585 std::uint32_t mFileDownloadQuota;
588 friend class FileTransferService;
594 mutable ReadWriteMutex mPropertiesMutex;
596 std::vector<TransportProtocol> mSupportedProtocols;
598 std::string mOpenSslCipherSuite;
602 tstring mSchannelCertificateValidation;
606 std::uint32_t mSessionTimeoutMs;
607 std::uint32_t mSessionHarvestingIntervalMs;
609 std::uint32_t mHttpSessionTimeoutMs;
611 OnCallbackConnectionCreated mOnCallbackConnectionCreated;
613 #if RCF_FEATURE_SSPI==1 614 DWORD mSchannelEnabledProtocols = 0;
615 ULONG mSchannelContextRequirements = 0;
623 std::uint32_t mServerObjectHarvestingIntervalS;
625 #if RCF_FEATURE_HTTP==1 626 Mutex mHttpSessionMapMutex;
627 std::map<std::string, HttpSessionPtr> mHttpSessionMap;
629 friend class HttpSessionFilter;
631 HttpSessionPtr attachHttpSession(
const std::string & httpSessionId,
bool allowCreate, ExceptionPtr & ePtr);
632 void detachHttpSession(HttpSessionPtr httpSessionPtr);
634 friend class ServerObjectService;
635 void harvestHttpSessions();
645 bool mEnableProxyEndpoints =
false;
651 #endif // ! INCLUDE_RCF_RCFSERVER_HPP RCF_FILESYSTEM_NS::path Path
Typedef for standard C++ path type.
Definition: FileSystem.hpp:35
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:347
Represents a server side session, associated with a client connection.
Definition: RcfSession.hpp:67
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:280
Base class for all client transports.
Definition: ClientTransport.hpp:75
Base class for all server transports.
Definition: ServerTransport.hpp:122
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:312
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...
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:288
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:85
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:149
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:323
Provides RCF server-side functionality.
Definition: RcfServer.hpp:54
bool unbind(const std::string &name="")
Removes a servant binding from the RcfServer.
Definition: RcfServer.hpp:166
Base class for all network endpoint types.
Definition: Endpoint.hpp:41
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:37
General configuration of a subscription.
Definition: SubscriptionService.hpp:91
Definition: AmiIoHandler.hpp:24
TransportType
Describes the transport types used by a RCF connection.
Definition: Enums.hpp:34
Represents a proxy endpoint.
Definition: ProxyEndpoint.hpp:46
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:333