18 #ifndef INCLUDE_RCF_SERVERTRANSPORT_HPP 19 #define INCLUDE_RCF_SERVERTRANSPORT_HPP 29 #include <RCF/Export.hpp> 31 #include <RCF/ThreadLibrary.hpp> 42 virtual std::string string()
const 55 class RCF_EXPORT NetworkSession :
public std::enable_shared_from_this<NetworkSession>
60 virtual ~NetworkSession();
62 virtual void postRead() = 0;
64 virtual void postWrite(std::vector<ByteBuffer> &byteBuffers) = 0;
65 virtual void postClose() = 0;
68 getServerTransport() = 0;
71 getRemoteAddress() = 0;
73 virtual bool isConnected() = 0;
76 virtual void setTransportFilters(
const std::vector<FilterPtr> &filters) = 0;
77 virtual void getTransportFilters(std::vector<FilterPtr> &filters) = 0;
78 void setEnableReconnect(
bool enableReconnect);
79 bool getEnableReconnect();
81 virtual void getWireFilters(std::vector<FilterPtr> &filters);
85 std::uint64_t getTotalBytesReceived()
const;
86 std::uint64_t getTotalBytesSent()
const;
88 RcfSessionPtr getSessionPtr()
const;
90 std::uint32_t getLastActivityTimestamp()
const;
91 void setLastActivityTimestamp();
94 bool mEnableReconnect;
95 std::uint64_t mBytesReceivedCounter;
96 std::uint64_t mBytesSentCounter;
97 std::uint32_t mLastActivityTimestampMs;
99 RcfSessionPtr mRcfSessionPtr;
103 typedef std::shared_ptr<NetworkSession> NetworkSessionPtr;
104 typedef std::weak_ptr<NetworkSession> NetworkSessionWeakPtr;
107 typedef std::shared_ptr<RcfSession> RcfSessionPtr;
109 typedef RcfSessionPtr SessionPtr;
112 typedef std::shared_ptr<ThreadPool> ThreadPoolPtr;
138 void setMaxIncomingMessageLength(std::size_t maxMessageLength);
141 std::size_t getMaxIncomingMessageLength()
const;
144 void setConnectionLimit(std::size_t connectionLimit);
147 std::size_t getConnectionLimit()
const;
150 void setInitialNumberOfConnections(std::size_t initialNumberOfConnections);
153 std::size_t getInitialNumberOfConnections()
const;
156 void setThreadPool(ThreadPoolPtr threadPoolPtr);
161 void setSupportedProtocols(
const std::vector<TransportProtocol> & protocols);
164 const std::vector<TransportProtocol> & getSupportedProtocols()
const;
168 void setRpcProtocol(RpcProtocol rpcProtocol);
169 RpcProtocol getRpcProtocol()
const;
174 RpcProtocol mRpcProtocol;
179 mutable ReadWriteMutex mReadWriteMutex;
180 std::size_t mMaxMessageLength;
181 std::size_t mConnectionLimit;
182 std::size_t mInitialNumberOfConnections;
184 std::vector<TransportProtocol> mSupportedProtocols;
188 Mutex mSessionsMutex;
189 std::set<NetworkSessionWeakPtr> mSessions;
193 template<
typename Iter>
194 void enumerateSessions(
const Iter & iter)
196 Lock lock(mSessionsMutex);
197 std::copy(mSessions.begin(), mSessions.end(), iter);
202 class ServerTransportEx
206 virtual ~ServerTransportEx() {}
209 createClientTransport(
215 RcfClientPtr stubEntryPtr,
216 bool keepClientConnection) = 0;
219 createClientTransport(
220 SessionPtr sessionPtr) = 0;
224 RCF_EXPORT std::size_t getDefaultMaxMessageLength();
226 RCF_EXPORT
void setDefaultMaxMessageLength(
227 std::size_t maxMessageLength);
231 #endif // ! INCLUDE_RCF_SERVERTRANSPORT_HPP Describes the network address of a remote peer.
Definition: ServerTransport.hpp:36
Represents a server side session, associated with a client connection.
Definition: RcfSession.hpp:64
Indicates that no remote address is available.
Definition: ServerTransport.hpp:52
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:43
Base class for all server transports.
Definition: ServerTransport.hpp:121
Base class for all network endpoint types.
Definition: Endpoint.hpp:40
Represents a server-side thread pool.
Definition: ThreadPool.hpp:78
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
std::shared_ptr< ServerTransport > ServerTransportPtr
Unique pointer wrapper for RCF::ServerTransport.
Definition: RcfFwd.hpp:46