@@ -41,6 +41,8 @@ class BCT_API socket
4141{
4242public:
4343 typedef std::shared_ptr<socket> ptr;
44+ typedef rpc::request_body::value_type rpc_in_value;
45+ typedef rpc::response_body::value_type rpc_out_value;
4446
4547 DELETE_COPY_MOVE (socket);
4648
@@ -104,11 +106,11 @@ class BCT_API socket
104106 // / -----------------------------------------------------------------------
105107
106108 // / Read full rpc request from the socket, handler posted to socket strand.
107- virtual void rpc_read (rpc:: response_t & out ,
109+ virtual void rpc_read (rpc_in_value& request ,
108110 count_handler&& handler) NOEXCEPT;
109111
110112 // / Write full rpc response to the socket, handler posted to socket strand.
111- virtual void rpc_write (const rpc:: response_t & model ,
113+ virtual void rpc_write (rpc_out_value&& response ,
112114 count_handler&& handler) NOEXCEPT;
113115
114116 // / HTTP (generic).
@@ -158,13 +160,46 @@ class BCT_API socket
158160 // / The socket was upgraded to a websocket (requires strand).
159161 virtual bool websocket () const NOEXCEPT;
160162
163+ // / Utility.
164+ asio::socket& get_transport () NOEXCEPT;
165+ void logx (const std::string& context, const boost_code& ec) const NOEXCEPT;
166+
161167private:
168+ struct read_rpc
169+ {
170+ typedef std::shared_ptr<read_rpc> ptr;
171+ using rpc_reader = rpc::request_body::reader;
172+
173+ read_rpc (rpc_in_value& request_) NOEXCEPT
174+ : value{}, reader{ value }
175+ {
176+ request_ = value;
177+ }
178+
179+ rpc_in_value value;
180+ rpc_reader reader;
181+ };
182+
183+ struct write_rpc
184+ {
185+ typedef std::shared_ptr<write_rpc> ptr;
186+ using rpc_writer = rpc::response_body::writer;
187+ using out_buffer = rpc_writer::out_buffer;
188+
189+ write_rpc (rpc_out_value&& response) NOEXCEPT
190+ : value{ std::move (response) }, writer{ value }
191+ {
192+ }
193+
194+ rpc_out_value value;
195+ rpc_writer writer;
196+ };
197+
162198 // stop
163199 // ------------------------------------------------------------------------
164200
165201 void do_stop () NOEXCEPT;
166202 void do_async_stop () NOEXCEPT;
167- asio::socket& get_transport () NOEXCEPT;
168203
169204 // wait
170205 // ------------------------------------------------------------------------
@@ -186,11 +221,9 @@ class BCT_API socket
186221 const count_handler& handler) NOEXCEPT;
187222
188223 // tcp (rpc)
189- void do_rpc_read (
190- std::reference_wrapper<rpc::response_t > out,
224+ void do_rpc_read (boost_code ec, size_t total, const read_rpc::ptr& in,
191225 const count_handler& handler) NOEXCEPT;
192- void do_rpc_write (
193- const std::reference_wrapper<const rpc::response_t >& in,
226+ void do_rpc_write (boost_code ec, size_t total, const write_rpc::ptr& out,
194227 const count_handler& handler) NOEXCEPT;
195228
196229 // http (generic)
@@ -228,8 +261,10 @@ class BCT_API socket
228261 const count_handler& handler) NOEXCEPT;
229262
230263 // tcp (rpc)
231- void handle_rpc_tcp (const boost_code& ec, size_t size,
232- const count_handler& handler) NOEXCEPT;
264+ void handle_rpc_read (boost_code ec, size_t size, size_t total,
265+ const read_rpc::ptr& in, const count_handler& handler) NOEXCEPT;
266+ void handle_rpc_write (boost_code ec, size_t size, size_t total,
267+ const write_rpc::ptr& out, const count_handler& handler) NOEXCEPT;
233268
234269 // http (generic)
235270 void handle_http_read (const boost_code& ec, size_t size,
0 commit comments