21 #ifndef INCLUDE_RCF_RCFSESSION_HPP 22 #define INCLUDE_RCF_RCFSESSION_HPP 29 #include <RCF/Any.hpp> 30 #include <RCF/Export.hpp> 32 #include <RCF/MethodInvocation.hpp> 34 #include <RCF/SerializationProtocol.hpp> 37 #if RCF_FEATURE_FILETRANSFER==1 42 #if RCF_FEATURE_SSPI==1 49 struct TypeInfoCompare
52 const std::type_info* lhs,
53 const std::type_info* rhs)
const 55 if (lhs->before(*rhs))
68 public std::enable_shared_from_this<RcfSession>
75 typedef std::function<void(RcfSession&)> OnWriteCompletedCallback;
76 typedef std::function<void(RcfSession&)> OnWriteInitiatedCallback;
77 typedef std::function<void(RcfSession&)> OnDestroyCallback;
79 typedef std::map<const std::type_info *, Any, TypeInfoCompare> SessionObjectMap;
80 SessionObjectMap mSessionObjects;
85 T * getSessionObjectImpl(
bool createIfDoesntExist)
87 typedef std::shared_ptr<T> TPtr;
89 const std::type_info & whichType =
typeid(T);
90 const std::type_info * pWhichType = &whichType;
92 SessionObjectMap::iterator iter = mSessionObjects.find(pWhichType);
93 if (iter != mSessionObjects.end())
95 Any & a = iter->second;
96 TPtr & tPtr = a.
get<TPtr>();
97 RCF_ASSERT(tPtr.get());
100 else if (createIfDoesntExist)
102 TPtr tPtr(
new T() );
103 mSessionObjects[pWhichType] = tPtr;
127 typedef std::shared_ptr<T> TPtr;
129 const std::type_info & whichType =
typeid(T);
130 const std::type_info * pWhichType = &whichType;
132 SessionObjectMap::iterator iter = mSessionObjects.find(pWhichType);
133 if (iter != mSessionObjects.end())
135 mSessionObjects.erase(iter);
143 deleteSessionObject<T>();
144 T * pt = getSessionObjectImpl<T>(
true);
148 RCF_THROW(
Exception(RcfError_SessionObjectNotCreated,
typeid(T).name()));
157 T * pt = getSessionObjectImpl<T>(createIfDoesntExist);
160 RCF_THROW(
Exception(RcfError_SessionObjectDoesNotExist,
typeid(T).name()));
169 T * pt = getSessionObjectImpl<T>(
false);
181 RcfClientPtr getDefaultStubEntryPtr();
182 void setDefaultStubEntryPtr(RcfClientPtr stubEntryPtr);
183 void setCachedStubEntryPtr(RcfClientPtr stubEntryPtr);
191 void setRequestUserData(
const std::string & userData);
194 std::string getRequestUserData();
197 void setResponseUserData(
const std::string & userData);
200 std::string getResponseUserData();
228 std::uint32_t getPingBackIntervalMs();
231 tstring getClientUserName();
235 getTransportProtocol();
240 #if RCF_FEATURE_SSPI==1 244 PCtxtHandle getTransportSecurityContext()
const;
248 PCtxtHandle getTransportProtocolSecurityContext()
const;
253 bool getEnableCompression();
262 time_t getConnectedAtTime()
const;
265 std::size_t getConnectionDuration()
const;
268 std::size_t getRemoteCallCount()
const;
271 std::uint64_t getTotalBytesReceived()
const;
274 std::uint64_t getTotalBytesSent()
const;
277 void setEnableSfPointerTracking(
bool enable);
280 bool getEnableSfPointerTracking()
const;
285 #if RCF_FEATURE_FILETRANSFER==1 297 void setAllowUploads(
bool allowUploads);
300 bool getAllowUploads()
const;
309 Path getUploadPath(
const std::string& uploadId);
320 void addOnWriteCompletedCallback(
321 const OnWriteCompletedCallback & onWriteCompletedCallback);
323 void extractOnWriteCompletedCallbacks(
324 std::vector<OnWriteCompletedCallback> & onWriteCompletedCallbacks);
326 void setOnDestroyCallback(
327 OnDestroyCallback onDestroyCallback);
331 void setEnableNativeWstringSerialization(
bool enable);
332 bool getEnableNativeWstringSerialization()
const;
334 void getMessageFilters(std::vector<FilterPtr> &filters)
const;
335 void getTransportFilters(std::vector<FilterPtr> &filters)
const;
337 void lockTransportFilters();
338 void unlockTransportFilters();
339 bool transportFiltersLocked();
341 SerializationProtocolIn & getSpIn();
342 SerializationProtocolOut & getSpOut();
345 void setFiltered(
bool filtered);
347 std::vector<FilterPtr> & getFilters();
349 void setCloseSessionAfterWrite(
bool close);
353 std::uint32_t getPingTimestamp();
354 void setPingTimestamp();
356 std::uint32_t getPingIntervalMs();
357 void setPingIntervalMs(std::uint32_t pingIntervalMs);
359 std::uint32_t getTouchTimestamp();
366 void setWeakThisPtr();
368 void cancelDownload();
370 #if RCF_FEATURE_FILETRANSFER==1 372 void addDownloadStream(
373 std::uint32_t sessionLocalId,
374 FileStream fileStream);
378 Mutex mStopCallInProgressMutex;
379 bool mStopCallInProgress;
400 friend class AllocateServerParameters;
419 friend class ServerParameters;
421 friend class PingBackService;
422 friend class FilterService;
424 friend class StubAccess;
429 std::vector<OnWriteCompletedCallback> mOnWriteCompletedCallbacks;
430 std::vector<OnWriteInitiatedCallback> mOnWriteInitiatedCallbacks;
431 OnDestroyCallback mOnDestroyCallback;
433 std::uint32_t mRuntimeVersion;
434 std::uint32_t mArchiveVersion;
436 bool mEnableSfPointerTracking;
438 bool mTransportFiltersLocked;
440 bool mEnableNativeWstringSerialization =
false;
442 SerializationProtocolIn mIn;
443 SerializationProtocolOut mOut;
446 std::vector<FilterPtr> mFilters;
449 MethodInvocationRequest mRequest;
451 bool mCloseSessionAfterWrite;
452 std::uint32_t mPingTimestamp;
453 std::uint32_t mPingIntervalMs;
454 std::uint32_t mTouchTimestamp;
456 PingBackTimerEntry mPingBackTimerEntry;
459 bool mWritingPingBack;
460 std::vector<ByteBuffer> mQueuedSendBuffers;
462 void clearParameters();
464 void onReadCompleted();
465 void onWriteCompleted();
467 void processRequest();
468 void processOobMessages();
472 void sendResponseException(
const std::exception &e);
473 void sendResponseUncaughtException();
475 void encodeRemoteException(
476 SerializationProtocolOut & out,
479 void sendSessionResponse();
481 void registerForPingBacks();
482 void unregisterForPingBacks();
489 I_Parameters * mpParameters;
490 std::vector<char> mParametersVec;
493 std::vector< std::vector<char> > mParmsVec;
497 RcfSessionWeakPtr mWeakThisPtr;
503 friend class UdpServerTransport;
504 friend class UdpNetworkSession;
505 friend class FileStreamImpl;
507 #if RCF_FEATURE_FILETRANSFER==1 511 friend class FileTransferService;
513 FileDownloadInfoPtr mDownloadInfoPtr;
514 FileUploadInfoPtr mUploadInfoPtr;
516 typedef std::map<std::uint32_t, FileUploadInfoPtr> SessionUploads;
517 typedef std::map<std::uint32_t, FileDownload> SessionDownloads;
519 SessionUploads mSessionUploads;
520 SessionDownloads mSessionDownloads;
526 RcfClientPtr mDefaultStubEntryPtr;
527 RcfClientPtr mCachedStubEntryPtr;
530 NetworkSession & getNetworkSession()
const;
531 void setNetworkSession(NetworkSession & networkSession);
533 #if RCF_FEATURE_HTTP==1 535 void getHttpFrameInfo(
536 std::string& requestLine,
537 std::vector< std::pair<std::string, std::string> >& headers);
542 friend class HttpSessionFilter;
543 NetworkSession * mpNetworkSession;
546 std::string mCurrentCallDesc;
550 bool getIsCallbackSession()
const;
551 void setIsCallbackSession(
bool isCallbackSession);
553 bool isConnected()
const;
557 void setConnectedAtTime(time_t connectedAtTime);
559 friend class SspiServerFilter;
560 friend class Win32NamedPipeNetworkSession;
562 tstring mClientUsername;
564 bool mEnableCompression;
566 bool mTransportProtocolVerified;
567 bool mIsCallbackSession;
569 time_t mConnectedAtTime;
571 std::size_t mRemoteCallCount;
576 #endif // ! INCLUDE_RCF_RCFSESSION_HPP Describes the network address of a remote peer.
Definition: ServerTransport.hpp:37
Generic container type used to hold arbitrary objects.
Definition: RCF/Any.hpp:64
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.
Contains details about the currently executing remote call.
Definition: MethodInvocation.hpp:63
Represents a server side session, associated with a client connection.
Definition: RcfSession.hpp:67
T & get()
Type-safe retrieval of the contained value. Throws an exception if T does not match the type of the c...
Definition: RCF/Any.hpp:104
std::shared_ptr< BandwidthQuota > BandwidthQuotaPtr
Reference counted wrapper for RCF::BandwidthQuota.
Definition: RcfFwd.hpp:127
Base class of RemoteCallContext.
Definition: RemoteCallContext.hpp:39
std::shared_ptr< Certificate > CertificatePtr
Reference counted wrapper for RCF::Certificate.
Definition: RcfFwd.hpp:108
RCF_EXPORT RcfSession & getCurrentRcfSession()
Can only be called from within the server-side implementation of a remote call. Returns a reference t...
Base class for all RCF exceptions.
Definition: Exception.hpp:64
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.
T & createSessionObject()
Creates a session object.
Definition: RcfSession.hpp:141
void deleteSessionObject()
Deletes a session object.
Definition: RcfSession.hpp:125
Provides RCF server-side functionality.
Definition: RcfServer.hpp:54
Represents an error that occurs on a RCF server and is transmitted back to the client.
Definition: Exception.hpp:153
Definition: ByteBuffer.hpp:40
TransportProtocol
Describes the transport protocols used by a RCF connection. Transport protocols are layered on top of...
Definition: Enums.hpp:63
Definition: AmiIoHandler.hpp:24
TransportType
Describes the transport types used by a RCF connection.
Definition: Enums.hpp:34
T * querySessionObject()
Queries for the existence of a session object.
Definition: RcfSession.hpp:167
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...
T & getSessionObject(bool createIfDoesntExist=false)
Retrieves a session object, and optionally creates it.
Definition: RcfSession.hpp:155