19 #ifndef INCLUDE_RCF_METHODINVOCATION_HPP
20 #define INCLUDE_RCF_METHODINVOCATION_HPP
25 #include <boost/shared_ptr.hpp>
27 #include <RCF/Filter.hpp>
28 #include <RCF/ByteBuffer.hpp>
29 #include <RCF/Export.hpp>
30 #include <RCF/Exception.hpp>
31 #include <RCF/SerializationProtocol_Base.hpp>
32 #include <RCF/Token.hpp>
39 typedef boost::shared_ptr<StubEntry> StubEntryPtr;
41 typedef boost::shared_ptr<RcfSession> RcfSessionPtr;
42 class SerializationProtocolIn;
43 class SerializationProtocolOut;
45 class MethodInvocationResponse;
46 class MethodInvocationRequest;
49 static const int Descriptor_Error = 0;
50 static const int Descriptor_Request = 1;
51 static const int Descriptor_Response = 2;
52 static const int Descriptor_FilteredPayload = 3;
54 void encodeServerError(RcfServer & server, ByteBuffer & byteBuffer,
int error);
55 void encodeServerError(RcfServer & server, ByteBuffer & byteBuffer,
int error,
int arg0,
int arg1);
59 class RemoteCallRequest
63 RemoteCallRequest(
const MethodInvocationRequest & req);
65 std::string mServantBindingName;
66 std::string mInterfaceName;
69 SerializationProtocol mSerializationProtocol;
72 boost::uint32_t mPingBackIntervalMs;
73 bool mUseNativeWstringSerialization;
74 bool mEnableSfPointerTracking;
78 class RCF_EXPORT MethodInvocationRequest : boost::noncopyable
81 MethodInvocationRequest();
87 const MethodInvocationRequest & rhs);
91 const std::string & service,
92 const std::string & subInterface,
94 SerializationProtocol serializationProtocol,
95 MarshalingProtocol marshalingProtocol,
99 bool ignoreRuntimeVersion,
100 boost::uint32_t pingBackIntervalMs,
102 bool useNativeWstringSerialization,
103 bool enableSfPointerTracking);
105 Token getToken()
const;
106 const std::string & getSubInterface()
const;
108 bool getOneway()
const;
109 bool getClose()
const;
110 const std::string & getService()
const;
111 void setService(
const std::string &service);
112 int getPingBackIntervalMs();
114 ByteBuffer encodeRequestHeader();
117 const std::vector<ByteBuffer> & buffers,
118 std::vector<ByteBuffer> & message,
119 const std::vector<FilterPtr> & filters);
122 const ByteBuffer & message,
123 ByteBuffer & messageBody,
124 RcfSessionPtr rcfSessionPtr,
125 RcfServer & rcfServer);
128 const RemoteException * pRe,
130 bool enableSfPointerTracking);
133 const ByteBuffer & message,
135 MethodInvocationResponse & response,
136 const std::vector<FilterPtr> & filters);
138 StubEntryPtr locateStubEntryPtr(
139 RcfServer & rcfServer);
143 friend class RcfSession;
144 friend class ClientStub;
145 friend class RemoteCallRequest;
147 void decodeFromMessage(
148 const ByteBuffer & message,
150 RcfServer * pRcfServer,
151 RcfSessionPtr rcfSessionPtr,
152 const std::vector<FilterPtr> & existingFilters);
154 void encodeToMessage(
155 std::vector<ByteBuffer> & message,
156 const std::vector<ByteBuffer> & buffers,
157 const std::vector<FilterPtr> & filters);
160 std::string mSubInterface;
162 SerializationProtocol mSerializationProtocol;
163 MarshalingProtocol mMarshalingProtocol;
166 std::string mService;
167 boost::uint32_t mRuntimeVersion;
168 bool mIgnoreRuntimeVersion;
169 int mPingBackIntervalMs;
170 boost::uint32_t mArchiveVersion;
171 ByteBuffer mRequestUserData;
172 ByteBuffer mResponseUserData;
173 bool mUseNativeWstringSerialization;
174 bool mEnableSfPointerTracking;
175 ByteBuffer mOutOfBandRequest;
176 ByteBuffer mOutOfBandResponse;
178 boost::shared_ptr<std::vector<char> > mVecPtr;
181 friend RCF::MemOstream& operator<<(RCF::MemOstream& os,
const MethodInvocationRequest& r)
184 << NAMEVALUE(r.mToken)
185 << NAMEVALUE(r.mSubInterface)
186 << NAMEVALUE(r.mFnId)
187 << NAMEVALUE(r.mSerializationProtocol)
188 << NAMEVALUE(r.mMarshalingProtocol)
189 << NAMEVALUE(r.mOneway)
190 << NAMEVALUE(r.mClose)
191 << NAMEVALUE(r.mService)
192 << NAMEVALUE(r.mRuntimeVersion)
193 << NAMEVALUE(r.mPingBackIntervalMs)
194 << NAMEVALUE(r.mArchiveVersion);
200 class RCF_EXPORT MethodInvocationResponse
203 MethodInvocationResponse();
205 bool isException()
const;
206 bool isError()
const;
207 int getError()
const;
210 bool getEnableSfPointerTracking()
const;
212 std::auto_ptr<RemoteException> getExceptionPtr();
215 friend class MethodInvocationRequest;
218 typedef std::auto_ptr<RemoteException> RemoteExceptionPtr;
221 RemoteExceptionPtr mExceptionPtr;
226 bool mEnableSfPointerTracking;
228 friend RCF::MemOstream& operator<<(RCF::MemOstream& os,
const MethodInvocationResponse& r)
230 os << NAMEVALUE(r.mException);
231 if (r.mExceptionPtr.get())
233 os << NAMEVALUE(*r.mExceptionPtr);
236 os << NAMEVALUE(r.mError);
239 os << NAMEVALUE(r.mErrorCode);
240 os << NAMEVALUE(r.mArg0);
241 os << NAMEVALUE(r.mArg1);
252 Omt_RequestTransportFilters = 1,
253 Omt_CreateCallbackConnection = 2,
254 Omt_RequestSubscription = 3
258 typedef boost::shared_ptr<OobMessage> OobMessagePtr;
259 typedef boost::shared_ptr< std::vector<char> > VecPtr;
261 class RCF_EXPORT OobMessage
265 OobMessage(
int runtimeVersion);
266 virtual ~OobMessage();
268 virtual OobMessageType getMessageType() = 0;
270 virtual void encodeRequest(ByteBuffer & buffer) = 0;
271 virtual void decodeRequest(
const ByteBuffer & buffer, std::size_t & pos) = 0;
273 virtual void encodeResponse(ByteBuffer & buffer);
274 virtual void decodeResponse(
const ByteBuffer & buffer);
277 void encodeRequestCommon(VecPtr vecPtr, std::size_t & pos);
280 static OobMessagePtr decodeRequestCommon(
const ByteBuffer & buffer);
283 void encodeResponseCommon(VecPtr vecPtr, std::size_t & pos);
284 void decodeResponseCommon(
const ByteBuffer & buffer, std::size_t & pos);
291 boost::uint32_t mResponseError;
292 std::string mResponseErrorString;
295 class RCF_EXPORT OobRequestTransportFilters :
public OobMessage
298 OobRequestTransportFilters(
int runtimeVersion);
300 OobRequestTransportFilters(
302 const std::vector<FilterPtr> &filters);
304 virtual OobMessageType getMessageType();
305 virtual void encodeRequest(ByteBuffer & buffer);
306 virtual void decodeRequest(
const ByteBuffer & buffer, std::size_t & pos);
308 std::vector<boost::int32_t> mFilterIds;
311 class RCF_EXPORT OobCreateCallbackConnection :
public OobMessage
314 OobCreateCallbackConnection(
int runtimeVersion);
316 virtual OobMessageType getMessageType();
317 virtual void encodeRequest(ByteBuffer & buffer);
318 virtual void decodeRequest(
const ByteBuffer & buffer, std::size_t & pos);
321 class RCF_EXPORT OobRequestSubscription :
public OobMessage
324 OobRequestSubscription(
int runtimeVersion);
326 OobRequestSubscription(
328 const std::string & publisherName,
329 boost::uint32_t subToPubPingIntervalMs);
331 virtual OobMessageType getMessageType();
332 virtual void encodeRequest(ByteBuffer & buffer);
333 virtual void decodeRequest(
const ByteBuffer & buffer, std::size_t & pos);
334 virtual void encodeResponse(ByteBuffer & buffer);
335 virtual void decodeResponse(
const ByteBuffer & buffer);
338 std::string mPublisherName;
339 boost::uint32_t mSubToPubPingIntervalMs;
340 boost::uint32_t mPubToSubPingIntervalMs;
346 #endif // ! INCLUDE_RCF_METHODINVOCATION_HPP