19 #ifndef INCLUDE_RCF_CLIENTTRANSPORT_HPP
20 #define INCLUDE_RCF_CLIENTTRANSPORT_HPP
26 #include <boost/cstdint.hpp>
27 #include <boost/weak_ptr.hpp>
29 #include <RCF/AsioFwd.hpp>
30 #include <RCF/Enums.hpp>
31 #include <RCF/Filter.hpp>
32 #include <RCF/ByteBuffer.hpp>
33 #include <RCF/Export.hpp>
38 typedef boost::shared_ptr<Endpoint> EndpointPtr;
43 typedef boost::shared_ptr<OverlappedAmi> OverlappedAmiPtr;
47 typedef boost::weak_ptr<RcfSession> RcfSessionWeakPtr;
49 class RCF_EXPORT ClientTransportCallback
52 ClientTransportCallback() : mpAsyncDispatcher() {}
53 virtual ~ClientTransportCallback() {}
54 virtual void onConnectCompleted(
bool alreadyConnected =
false) = 0;
55 virtual void onSendCompleted() = 0;
56 virtual void onReceiveCompleted() = 0;
57 virtual void onTimerExpired() = 0;
58 virtual void onError(
const std::exception &e) = 0;
60 void setAsyncDispatcher(RcfServer & server);
61 RcfServer * getAsyncDispatcher();
63 virtual bool isClientStub()
const {
return false; }
66 RcfServer * mpAsyncDispatcher;
84 virtual TransportType getTransportType() = 0;
88 void setMaxIncomingMessageLength(std::size_t maxMessageLength);
91 std::size_t getMaxIncomingMessageLength()
const;
94 std::size_t getLastRequestSize();
97 std::size_t getLastResponseSize();
100 boost::uint64_t getRunningTotalBytesSent();
103 boost::uint64_t getRunningTotalBytesReceived();
106 void resetRunningTotals();
113 std::auto_ptr<ClientTransport> clone()
const = 0;
116 EndpointPtr getEndpointPtr()
const = 0;
120 ClientTransportCallback & clientStub,
121 const std::vector<ByteBuffer> & data,
122 unsigned int timeoutMs) = 0;
126 ClientTransportCallback & clientStub,
127 ByteBuffer & byteBuffer,
128 unsigned int timeoutMs) = 0;
131 bool isConnected() = 0;
135 ClientTransportCallback & clientStub,
136 unsigned int timeoutMs) = 0;
140 unsigned int timeoutMs = 0) = 0;
143 void setTransportFilters(
144 const std::vector<FilterPtr> & filters) = 0;
147 void getTransportFilters(
148 std::vector<FilterPtr> & filters) = 0;
151 void setMaxMessageLength(std::size_t maxMessageLength);
152 std::size_t getMaxMessageLength()
const;
155 RcfSessionWeakPtr getRcfSession();
156 void setRcfSession(RcfSessionWeakPtr rcfSessionWeakPtr);
159 void setAsync(
bool async);
161 virtual void cancel();
163 virtual void setTimer(
164 boost::uint32_t timeoutMs,
165 ClientTransportCallback * pClientStub = NULL) = 0;
167 virtual void associateWithIoService(AsioIoService & ioService);
168 virtual bool isAssociatedWithIoService();
170 virtual bool supportsTransportFilters()
176 std::size_t mMaxMessageLength;
177 RcfSessionWeakPtr mRcfSessionWeakPtr;
180 std::size_t mLastRequestSize;
181 std::size_t mLastResponseSize;
183 boost::uint64_t mRunningTotalBytesSent;
184 boost::uint64_t mRunningTotalBytesReceived;
188 friend class ClientStub;
191 typedef boost::shared_ptr<ClientTransport> ClientTransportPtr;
193 typedef std::auto_ptr<ClientTransport> ClientTransportAutoPtr;
195 typedef boost::shared_ptr< ClientTransportAutoPtr > ClientTransportAutoPtrPtr;
199 #endif // ! INCLUDE_RCF_CLIENTTRANSPORT_HPP