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();
262 void setHttpServerHeader(
const std::string & httpServerHeader);
265 std::string getHttpServerHeader()
const;
267 #if RCF_FEATURE_HTTP==1 284 std::uint32_t getServerObjectHarvestingIntervalS()
const;
287 void setServerObjectHarvestingIntervalS(std::uint32_t harvestingIntervalS);
292 const std::string & objectKey)
294 return mServerObjectServicePtr->queryServerObject<T>(objectKey);
300 const std::string & objectKey,
301 std::uint32_t timeoutMs)
303 return mServerObjectServicePtr->getServerObject<T>(objectKey, timeoutMs);
307 void deleteServerObject(
const std::string & objectKey);
311 #if RCF_FEATURE_PUBSUB==1 322 template<
typename Interface>
326 return mPublishingServicePtr->createPublisher<Interface>(parms);
333 template<
typename Interface>
337 return mPublishingServicePtr->createPublisher<Interface>(parms);
343 template<
typename Interface,
typename T>
348 RCF_ASSERT(mStarted);
351 return mSubscriptionServicePtr->createSubscription<Interface>(servantObj, publisherEp);
357 template<
typename Interface,
typename T>
362 RCF_ASSERT(mStarted);
363 return mSubscriptionServicePtr->createSubscription<Interface>(servantObj, parms);
371 void setEnableProxyEndpoints(
bool enable);
374 bool getEnableProxyEndpoints()
const;
376 #if RCF_FEATURE_FILETRANSFER==1 384 void setUploadBandwidthLimit(std::uint32_t uploadQuotaBps);
387 std::uint32_t getUploadBandwidthLimit()
const;
390 void setDownloadBandwidthLimit(std::uint32_t downloadQuotaBps);
393 std::uint32_t getDownloadBandwidthLimit()
const;
396 void setUploadDirectory(
const Path & uploadDir);
399 Path getUploadDirectory()
const;
429 void setOnCallbackConnectionCreated(OnCallbackConnectionCreated onCallbackConnectionCreated);
430 OnCallbackConnectionCreated getOnCallbackConnectionCreated();
441 getServerTransportService();
444 getServerTransportPtr();
449 ServicePtr servicePtr);
452 ServicePtr servicePtr);
457 getPingBackServicePtr();
459 FileTransferServicePtr
460 getFileTransferServicePtr();
462 SessionTimeoutServicePtr
463 getSessionTimeoutServicePtr();
466 getPublishingServicePtr();
468 SubscriptionServicePtr
469 getSubscriptionServicePtr();
471 FilterServicePtr getFilterServicePtr();
473 bool addServerTransport(
476 bool removeServerTransport(
484 void setStartCallback(
const StartCallback &startCallback);
487 void invokeStartCallback();
491 const std::string &name,
492 RcfClientPtr rcfClientPtr);
498 SessionPtr createSession();
499 void onReadCompleted(SessionPtr sessionPtr);
500 void onWriteCompleted(SessionPtr sessionPtr);
509 template<
typename Iter>
510 void enumerateSessions(
const Iter & iter)
512 for (std::size_t i=0; i<mServerTransports.size(); ++i)
514 mServerTransports[i]->enumerateSessions(iter);
522 ReadWriteMutex mStubMapMutex;
523 typedef std::map<std::string, RcfClientPtr> StubMap;
527 typedef std::function<void(const JsonRpcRequest &, JsonRpcResponse &)> JsonRpcMethod;
528 typedef std::map<std::string, JsonRpcMethod> JsonRpcMethods;
529 JsonRpcMethods mJsonRpcMethods;
539 std::vector<ServerTransportPtr> mServerTransports;
540 std::vector<ServicePtr> mServices;
541 FilterServicePtr mFilterServicePtr;
542 PingBackServicePtr mPingBackServicePtr;
543 FileTransferServicePtr mFileTransferServicePtr;
544 SessionTimeoutServicePtr mSessionTimeoutServicePtr;
545 PublishingServicePtr mPublishingServicePtr;
546 SubscriptionServicePtr mSubscriptionServicePtr;
547 CallbackConnectionServicePtr mCallbackConnectionServicePtr;
548 ProxyEndpointServicePtr mProxyEndpointServicePtr;
549 ServerObjectServicePtr mServerObjectServicePtr;
551 void startService(ServicePtr servicePtr)
const;
552 void stopService(ServicePtr servicePtr)
const;
553 void resolveServiceThreadPools(ServicePtr servicePtr)
const;
555 friend class AsioNetworkSession;
556 FilterPtr createFilter(
int filterId);
559 StartCallback mStartCallback;
560 Condition mStartEvent;
561 Condition mStopEvent;
563 Mutex mStartStopMutex;
567 ThreadPoolPtr mThreadPoolPtr;
572 friend class MethodInvocationRequest;
575 std::uint32_t mRuntimeVersion;
576 std::uint32_t mArchiveVersion;
581 #if RCF_FEATURE_FILETRANSFER==1 584 Path getUploadPath(
const std::string & uploadId);
591 Path mFileUploadDirectory;
593 std::uint32_t mFileUploadQuota;
596 std::uint32_t mFileDownloadQuota;
599 friend class FileTransferService;
605 mutable ReadWriteMutex mPropertiesMutex;
607 std::vector<TransportProtocol> mSupportedProtocols;
609 std::string mOpenSslCipherSuite;
613 tstring mSchannelCertificateValidation;
617 std::uint32_t mSessionTimeoutMs;
618 std::uint32_t mSessionHarvestingIntervalMs;
620 std::uint32_t mHttpSessionTimeoutMs;
622 std::string mHttpServerHeader;
624 OnCallbackConnectionCreated mOnCallbackConnectionCreated;
626 #if RCF_FEATURE_SSPI==1 627 DWORD mSchannelEnabledProtocols = 0;
628 ULONG mSchannelContextRequirements = 0;
636 std::uint32_t mServerObjectHarvestingIntervalS;
638 friend class HttpSessionFilter;
640 HttpSessionPtr attachHttpSession(
const std::string & httpSessionId,
bool allowCreate, ExceptionPtr & ePtr);
641 void detachHttpSession(HttpSessionPtr httpSessionPtr);
643 friend class ServerObjectService;
644 void harvestHttpSessions();
646 #if RCF_FEATURE_HTTP==1 647 Mutex mHttpSessionMapMutex;
648 std::map<std::string, HttpSessionPtr> mHttpSessionMap;
661 bool mEnableProxyEndpoints =
false;
667 #endif // ! INCLUDE_RCF_RCFSERVER_HPP RCF_FILESYSTEM_NS::path Path
Typedef for standard C++ path type.
Definition: FileSystem.hpp:32
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:135
std::shared_ptr< Subscription > createSubscription(T &servantObj, const SubscriptionParms &parms)
Creates a subscription to a remote RCF publisher.
Definition: RcfServer.hpp:358
Represents a server side session, associated with a client connection.
Definition: RcfSession.hpp:65
std::shared_ptr< Certificate > CertificatePtr
Reference counted wrapper for RCF::Certificate.
Definition: RcfFwd.hpp:109
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:44
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:291
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:147
std::function< bool(Certificate *)> CertificateValidationCallback
Describes user-provided callback functions for validating a certificate.
Definition: RcfFwd.hpp:115
std::shared_ptr< Publisher< Interface > > createPublisher()
Creates a publisher instance for the given RCF interface.
Definition: RcfServer.hpp:323
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:61
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:299
BandwidthQuotaCallback UploadBandwidthQuotaCallback
Describes user-provided callback functions for assigning custom bandwidth quotas to a RcfSession...
Definition: RcfFwd.hpp:144
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:249
std::shared_ptr< Publisher< Interface > > createPublisher(const PublisherParms &parms)
Creates a publisher instance for the given RCF interface.
Definition: RcfServer.hpp:334
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:138
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:47
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:344