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();
64 RcfServer * mpAsyncDispatcher;
82 virtual TransportType getTransportType() = 0;
86 void setMaxIncomingMessageLength(std::size_t maxMessageLength);
89 std::size_t getMaxIncomingMessageLength()
const;
92 std::size_t getLastRequestSize();
95 std::size_t getLastResponseSize();
98 boost::uint64_t getRunningTotalBytesSent();
101 boost::uint64_t getRunningTotalBytesReceived();
104 void resetRunningTotals();
111 std::auto_ptr<ClientTransport> clone()
const = 0;
114 EndpointPtr getEndpointPtr()
const = 0;
118 ClientTransportCallback & clientStub,
119 const std::vector<ByteBuffer> & data,
120 unsigned int timeoutMs) = 0;
124 ClientTransportCallback & clientStub,
125 ByteBuffer & byteBuffer,
126 unsigned int timeoutMs) = 0;
129 bool isConnected() = 0;
133 ClientTransportCallback & clientStub,
134 unsigned int timeoutMs) = 0;
138 unsigned int timeoutMs = 0) = 0;
141 void setTransportFilters(
142 const std::vector<FilterPtr> & filters) = 0;
145 void getTransportFilters(
146 std::vector<FilterPtr> & filters) = 0;
149 void setMaxMessageLength(std::size_t maxMessageLength);
150 std::size_t getMaxMessageLength()
const;
153 RcfSessionWeakPtr getRcfSession();
154 void setRcfSession(RcfSessionWeakPtr rcfSessionWeakPtr);
157 void setAsync(
bool async);
159 virtual void cancel();
161 virtual void setTimer(
162 boost::uint32_t timeoutMs,
163 ClientTransportCallback * pClientStub = NULL) = 0;
165 virtual void associateWithIoService(AsioIoService & ioService);
166 virtual bool isAssociatedWithIoService();
168 virtual bool isInProcess();
169 virtual void doInProcessCall(ClientStub & clientStub);
171 virtual bool supportsTransportFilters()
177 std::size_t mMaxMessageLength;
178 RcfSessionWeakPtr mRcfSessionWeakPtr;
181 std::size_t mLastRequestSize;
182 std::size_t mLastResponseSize;
184 boost::uint64_t mRunningTotalBytesSent;
185 boost::uint64_t mRunningTotalBytesReceived;
189 friend class ClientStub;
192 typedef boost::shared_ptr<ClientTransport> ClientTransportPtr;
194 typedef std::auto_ptr<ClientTransport> ClientTransportAutoPtr;
196 typedef boost::shared_ptr< ClientTransportAutoPtr > ClientTransportAutoPtrPtr;
200 #endif // ! INCLUDE_RCF_CLIENTTRANSPORT_HPP