Remote Call Framework 3.0
HttpSessionFilter.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2018, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 3.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_HTTPSESSIONFILTER_HPP
20 #define INCLUDE_RCF_HTTPSESSIONFILTER_HPP
21 
22 #include <RCF/Filter.hpp>
23 #include <RCF/ByteBuffer.hpp>
24 
25 #include <cstdint>
26 
27 namespace RCF {
28 
29  class AsioNetworkSession;
30 
31  class RcfSession;
32  typedef std::shared_ptr<RcfSession> RcfSessionPtr;
33 
34  class HttpSession
35  {
36  public:
37 
38  HttpSession(const std::string & httpSessionId);
39  ~HttpSession();
40 
41  RcfSessionPtr mRcfSessionPtr;
42 
43  bool mRequestInProgress;
44  std::uint32_t mLastTouchMs;
45 
46  std::string mHttpSessionId;
47  std::uint32_t mHttpSessionIndex;
48  std::vector<FilterPtr> mTransportFilters;
49 
50  ByteBuffer mCachedReadBuffer;
51  std::size_t mCachedReadBytesRequested;
52  };
53 
54  typedef std::shared_ptr<HttpSession> HttpSessionPtr;
55 
56  class HttpSessionFilter : public Filter
57  {
58  public:
59 
60  HttpSessionFilter(AsioNetworkSession& networkSession);
61  ~HttpSessionFilter();
62 
63  virtual void resetState();
64 
65  virtual void read(
66  const ByteBuffer &byteBuffer,
67  std::size_t bytesRequested);
68 
69  virtual void onReadCompleted(const ByteBuffer &byteBuffer);
70 
71  virtual void write(const std::vector<ByteBuffer> &byteBuffers);
72 
73  virtual void onWriteCompleted(std::size_t bytesTransferred);
74 
75  virtual int getFilterId() const;
76 
77  ByteBuffer mReadBuffer;
78 
79  std::vector<ByteBuffer> mWriteBuffers;
80 
81  AsioNetworkSession & mNetworkSession;
82  HttpSessionPtr mHttpSessionPtr;
83 
84  const std::vector<FilterPtr> mNoFilters;
85 
86  char mDummy;
87  };
88 
89 } // namespace RCF
90 
91 #endif // ! INCLUDE_RCF_HTTPSESSIONFILTER_HPP
Definition: AmiIoHandler.hpp:24