{"id":279957,"date":"2016-10-26T12:20:02","date_gmt":"2016-10-26T08:20:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=279957"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=279957","title":{"rendered":"JSON-RPC \u043d\u0430 C++"},"content":{"rendered":"<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habrahabr.ru\/post\/311262\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043f\u0440\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 JSON-\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 C++ \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u0442.\u043a. \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043d\u043e \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.\u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u2014 \u0435\u0441\u043b\u0438 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0442\u043e \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u0438 \u0432 wjrpc, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 wjrpc \u201c\u0432\u044b\u0434\u0440\u0430\u043d\u201d \u0438\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u043f\u043e\u0434 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u0431\u044b\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d, \u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<p>\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c JSON-\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 wjrpc \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f JSON-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041f\u0440\u043e <a href=\"https:\/\/github.com\/mambaru\/wjson\">wjson<\/a> \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f API \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0434\u043b\u044f JSON-RPC, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u043e\u0440 \u0432 \u201c\u0432\u0440\u0443\u0447\u043d\u0443\u044e\u201d. \u042d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 run-time \u043a\u043e\u0434\u0430 \u043f\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u043d\u043e \u043e\u043d \u043f\u0440\u043e\u0449\u0435 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 examples \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c API \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0421\u0430\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">calc\/api\/plus.hpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#pragma once #include &lt;memory&gt; #include &lt;functional&gt;  namespace request {     struct plus     {         int first=0;         int second=0;         typedef std::unique_ptr&lt;plus&gt; ptr;     }; } \/\/ request  namespace response {     struct plus     {         int value=0;         typedef std::unique_ptr&lt;plus&gt; ptr;         typedef std::function&lt;void(ptr)&gt; callback;     }; } \/\/ response<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441-\u043e\u0442\u0432\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u043f\u043a\u0435. \u042d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0435\u043d \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430. \u0421\u043c\u044b\u0441\u043b \u044d\u0442\u0438\u0445 typedef-\u043e\u0432 \u043f\u043e\u044f\u0441\u043d\u044e \u043f\u043e\u0437\u0434\u043d\u0435\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 JSON.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">calc\/api\/plus_json.hpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#pragma once #include &quot;calc\/api\/plus.hpp&quot; #include &lt;wjson\/json.hpp&gt; #include &lt;wjson\/name.hpp&gt;  namespace request {     struct plus_json     {         JSON_NAME(first)         JSON_NAME(second)          typedef wjson::object&lt;             plus,             wjson::member_list&lt;                 wjson::member&lt;n_first, plus, int, &amp;plus::first&gt;,                 wjson::member&lt;n_second, plus, int, &amp;plus::second&gt;             &gt;         &gt; type;         typedef typename type::serializer serializer;         typedef typename type::target target;     }; }  namespace response {     struct plus_json     {         JSON_NAME(value)         typedef wjson::object&lt;             plus,             wjson::member_list&lt;                 wjson::member&lt;n_value, plus, int, &amp;plus::value&gt;             &gt;         &gt; type;         typedef typename type::serializer serializer;         typedef typename type::target target;     }; }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u043e\u0439 wjson. \u041e\u0442\u043c\u0435\u0447\u0443 \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f typedef-\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u044b \u043a\u0430\u043a json-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 JSON-RPC \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430. \u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u0430 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 JSON-RPC \u0434\u043b\u044f plus<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>&lt;p&gt;{ &quot;jsonrpc&quot;:&quot;2.0&quot;, &quot;method&quot;:&quot;plus&quot;, &quot;params&quot;:{ &quot;first&quot;:2, &quot;second&quot;:3 }, &quot;id&quot;:1 }&lt;\/p&gt; &lt;source&gt;&lt;!--&lt;\/spoiler&gt;--&gt; \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443: &lt;!--&lt;spoiler title=&quot;\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432&quot;&gt;--&gt; ```cpp struct request {     std::string version,     std::string method,     std::string params,     std::string id }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">JSON-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">JSON_NAME(jsonrpc) JSON_NAME(method) JSON_NAME(params) JSON_NAME(id)  typedef wjson::object&lt;     request,     wjson::member_list&lt;         wjson::member&lt;n_jsonrpc, request, std::string, &amp;request::version&gt;,         wjson::member&lt;n_method, request, std::string, &amp;request::method&gt;,         wjson::member&lt;n_params, request, std::string, &amp;request::params, json::raw_value&lt;&gt; &gt;,         wjson::member&lt;n_id, request, std::string, &amp;request::id, json::raw_value&lt;&gt; &gt;     &gt; &gt; request_json;<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0432 \u043f\u043e\u043b\u044f <code>request::params<\/code> \u0438 <code>request::id<\/code> json \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u0435\u0441\u0442\u044c, \u0431\u0435\u0437 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0432 \u043f\u043e\u043b\u0435 <code>request::method<\/code> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u043c\u043e\u0436\u0435\u043c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c, \u0430 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0443\u0441\u043e\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0439\u0441\u044f \u043a \u043f\u043e\u043b\u044e params. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e wjson::parser \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043d\u043e wjson \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e raw_pair (\u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0435\u0435 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0435 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0430 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0431\u0443\u0444\u0435\u0440\u0435. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 wjrpc.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e wjrpc \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 std::string, \u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0438\u043f\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">namespace wjrpc {     typedef std::vector&lt;char&gt; data_type;     typedef std::unique_ptr&lt;data_type&gt; data_ptr; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c data_ptr \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u044b\u0439 \u0431\u0443\u0444\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u043d\u0435\u0434\u043e\u0441\u043c\u043e\u0442\u0440\u0443.<\/p>\n<p>  <\/p>\n<p>\u041b\u044e\u0431\u043e\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 wjrpc \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">wjrpc::incoming<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">namespace wjrpc {     struct incoming     {         typedef data_type::iterator iterator;         typedef std::pair&lt;iterator, iterator&gt; pair_type;         pair_type method;         pair_type params;         pair_type result;         pair_type error;         pair_type id;     }; }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b wjrpc::incoming \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0430\u0440\u044b \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0431\u0443\u0444\u0435\u0440\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, method.first \u043f\u0440\u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u0432\u044b\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f, \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u0430 method.second \u2014 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u043a\u0430\u0432\u044b\u0447\u043a\u0438. \u042d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441, \u043d\u043e \u0438 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044f\u043c. JSON -\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">wjrpc::incoming_json<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">namespace wjrpc {     struct incoming_json     {         typedef incoming::pair_type pair_type;         typedef wjson::iterator_pair&lt;pair_type&gt; pair_json;          JSON_NAME(id)         JSON_NAME(method)         JSON_NAME(params)         JSON_NAME(result)         JSON_NAME(error)          typedef wjson::object&lt;             incoming,             wjson::member_list&lt;                 wjson::member&lt;n_method, incoming, pair_type, &amp;incoming::method, pair_json&gt;,                 wjson::member&lt;n_params, incoming, pair_type, &amp;incoming::params, pair_json&gt;,                 wjson::member&lt;n_result, incoming, pair_type, &amp;incoming::result, pair_json&gt;,                 wjson::member&lt;n_error, incoming, pair_type, &amp;incoming::error, pair_json&gt;,                 wjson::member&lt;n_id, incoming, pair_type, &amp;incoming::id, pair_json&gt;             &gt;         &gt; type;          typedef type::target target;         typedef type::member_list member_list;         typedef type::serializer serializer;     }; }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 \u044d\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0431\u0443\u0444\u0435\u0440\u0435. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u0430\u043a\u043e\u0439 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0430\u043b\u0438\u0434\u043d\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 wjrpc::incoming_holder \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u0443\u0444\u0435\u0440 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0438 \u043f\u0430\u0440\u0441\u0438\u0442 \u0435\u0433\u043e \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u043e \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 JSON-RPC.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043e\u0434\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;calc\/api\/plus.hpp&quot; #include &quot;calc\/api\/plus_json.hpp&quot;  #include &lt;wjrpc\/errors\/error_json.hpp&gt; #include &lt;wjrpc\/incoming\/incoming_holder.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_holder.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_result.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_result_json.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_error.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_error_json.hpp&gt;  #include &lt;iostream&gt;  int main() {     std::vector&lt;std::string&gt; req_list =     {         &quot;{\\&quot;method\\&quot;:\\&quot;plus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;minus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:5, \\&quot;second\\&quot;:10 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;multiplies\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:2 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;divides\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:9, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;     };     std::vector&lt;std::string&gt; res_list;      for ( auto&amp; sreq : req_list )     {         wjrpc::incoming_holder inholder( sreq );         \/\/ \u041f\u0430\u0440\u0441\u0438\u043c \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438         inholder.parse(nullptr);          \/\/ \u0415\u0441\u0442\u044c \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u0437\u043e\u0432\u0430         if ( inholder.method() == &quot;plus&quot; )         {             \/\/ \u0414\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a             auto params = inholder.get_params&lt;request::plus_json&gt;(nullptr);             \/\/ \u041e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430             wjrpc::outgoing_result&lt;response::plus&gt; res;             res.result = std::make_unique&lt;response::plus&gt;();              \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e             res.result-&gt;value = params-&gt;first + params-&gt;second;             \/\/ \u0417\u0430\u0431\u0438\u0440\u0430\u0435\u043c id \u0432 \u0441\u044b\u0440\u043e\u043c \u0432\u0438\u0434\u0435 \u043a\u0430\u043a \u0435\u0441\u0442\u044c             auto raw_id = inholder.raw_id();             res.id = std::make_unique&lt;wjrpc::data_type&gt;( raw_id.first, raw_id.second );             \/\/ \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0442\u0432\u0435\u0442\u0430             typedef wjrpc::outgoing_result_json&lt;response::plus_json&gt; result_json;             res_list.push_back(std::string());             result_json::serializer()( res, std::back_inserter(res_list.back()) );         }         \/* else if ( inholder.method() == &quot;minus&quot; ) { ... } *\/         \/* else if ( inholder.method() == &quot;multiplies&quot; ) { ... } *\/         \/* else if ( inholder.method() == &quot;divides&quot; ) { ... } *\/     }      for ( size_t i =0; i != res_list.size(); ++i)     {         std::cout &lt;&lt; req_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; res_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; std::endl;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c incoming_holder \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438 \u043f\u0430\u0440\u0441\u0438\u043c \u0435\u0435. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 incoming. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u044e\u0431\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 json-\u043e\u0431\u044a\u0435\u043a\u0442, \u0442\u043e \u044d\u0442\u043e\u0442 \u044d\u0442\u0430\u043f \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044e \u043f\u043e\u043b\u0435\u0439 \u201cmethod\u201d, \u201cresult\u201d, \u201cerror\u201d \u0438 \u201cid\u201d.<\/p>\n<p>  <\/p>\n<table>\n<thead>\n<tr>\n<th>\u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f<\/th>\n<th>\u0422\u0438\u043f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/th>\n<th>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430<\/th>\n<th>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>method \u0438 id<\/td>\n<td>\u0437\u0430\u043f\u0440\u043e\u0441<\/td>\n<td>is_request<\/td>\n<td>get_params&lt;&gt;<\/td>\n<\/tr>\n<tr>\n<td>method \u0431\u0435\u0437 id<\/td>\n<td>\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435<\/td>\n<td>is_notify<\/td>\n<td>get_params&lt;&gt;<\/td>\n<\/tr>\n<tr>\n<td>result \u0438 id<\/td>\n<td>\u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/td>\n<td>is_response<\/td>\n<td>get_result&lt;&gt;<\/td>\n<\/tr>\n<tr>\n<td>error \u0438 id<\/td>\n<td>\u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/td>\n<td>is_request_error<\/td>\n<td>get_error&lt;&gt;<\/td>\n<\/tr>\n<tr>\n<td>error \u0431\u0435\u0437 id<\/td>\n<td>\u043f\u0440\u043e\u0447\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/td>\n<td>is_other_error<\/td>\n<td>get_error&lt;&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u0438 \u043e\u0434\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;calc\/api\/plus.hpp&quot; #include &quot;calc\/api\/plus_json.hpp&quot;  #include &lt;wjrpc\/errors\/error_json.hpp&gt; #include &lt;wjrpc\/incoming\/incoming_holder.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_holder.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_result.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_result_json.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_error.hpp&gt; #include &lt;wjrpc\/outgoing\/outgoing_error_json.hpp&gt; #include &lt;iostream&gt;  int main() {     std::vector&lt;std::string&gt; req_list =     {         &quot;{\\&quot;method\\&quot;:\\&quot;plus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;minus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:5, \\&quot;second\\&quot;:10 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;multiplies\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:2 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;divides\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:9, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;     };     std::vector&lt;std::string&gt; res_list;      for ( auto&amp; sreq : req_list )     {         wjrpc::incoming_holder inholder( sreq );         wjson::json_error e;         inholder.parse(&amp;e);         if ( e )         {             typedef wjrpc::outgoing_error&lt;wjrpc::error&gt; error_type;             error_type err;             err.error = std::make_unique&lt;wjrpc::parse_error&gt;();              typedef wjrpc::outgoing_error_json&lt;wjrpc::error_json&gt; error_json;             std::string str;             error_json::serializer()(err, std::back_inserter(str));             res_list.push_back(str);         }         else if ( inholder.is_request() )         {             auto raw_id = inholder.raw_id();             auto call_id = std::make_unique&lt;wjrpc::data_type&gt;( raw_id.first, raw_id.second );             \/\/ \u0415\u0441\u0442\u044c \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u0437\u043e\u0432\u0430             if ( inholder.method() == &quot;plus&quot; )             {                 auto params = inholder.get_params&lt;request::plus_json&gt;(&amp;e);                 if ( !e )                 {                     wjrpc::outgoing_result&lt;response::plus&gt; res;                     res.result = std::make_unique&lt;response::plus&gt;();                     res.result-&gt;value = params-&gt;first + params-&gt;second;                     res.id = std::move(call_id);                     typedef wjrpc::outgoing_result_json&lt;response::plus_json&gt; result_json;                     std::string str;                     result_json::serializer()( res, std::back_inserter(str) );                     res_list.push_back(str);                 }                 else                 {                     typedef wjrpc::outgoing_error&lt;wjrpc::error&gt; error_type;                     error_type err;                     err.error = std::make_unique&lt;wjrpc::invalid_params&gt;();                     err.id = std::move(call_id);                      typedef wjrpc::outgoing_error_json&lt;wjrpc::error_json&gt; error_json;                     std::string str;                     error_json::serializer()(err, std::back_inserter(str));                     res_list.push_back(str);                 }             }             \/* else if ( inholder.method() == &quot;minus&quot; ) { ... } *\/             \/* else if ( inholder.method() == &quot;multiplies&quot; ) { ... } *\/             \/* else if ( inholder.method() == &quot;divides&quot; ) { ... } *\/             else             {                 typedef wjrpc::outgoing_error&lt;wjrpc::error&gt; error_type;                 error_type err;                 err.error = std::make_unique&lt;wjrpc::procedure_not_found&gt;();                 err.id = std::move(call_id);                  typedef wjrpc::outgoing_error_json&lt;wjrpc::error_json&gt; error_json;                 std::string str;                 error_json::serializer()(err, std::back_inserter(str));                 res_list.push_back(str);             }         }         else         {             typedef wjrpc::outgoing_error&lt;wjrpc::error&gt; error_type;             error_type err;             err.error = std::make_unique&lt;wjrpc::invalid_request&gt;();              typedef wjrpc::outgoing_error_json&lt;wjrpc::error_json&gt; error_json;             std::string str;             error_json::serializer()(err, std::back_inserter(str));             res_list.push_back(str);         }     }      for ( size_t i =0; i != res_list.size(); ++i)     {         std::cout &lt;&lt; req_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; res_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; std::endl;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u2014 \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435, \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u041d\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u043e\u0448\u0438\u0431\u043e\u043a \u043a\u043e\u0434 \u043f\u043e\u0445\u043e\u0436\u0438\u0439, \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0438\u043f\u0435 \u043e\u0448\u0438\u0431\u043a\u0438. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename E&gt; void make_error(wjrpc::incoming_holder inholder, std::string&amp; out) {     typedef wjrpc::outgoing_error&lt;wjrpc::error&gt; common_error;     common_error err;     err.error = std::make_unique&lt;E&gt;();     if ( inholder.has_id() )     {         auto id = inholder.raw_id();         err.id = std::make_unique&lt;wjrpc::data_type&gt;(id.first, id.second);     }      typedef wjrpc::outgoing_error_json&lt;wjrpc::error_json&gt; error_json;     error_json::serializer()(err, std::back_inserter(out)); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0442\u0438\u043f \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u0437\u043e\u0432\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c. \u041e\u0431\u044a\u0435\u043a\u0442 inholder \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u044b\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0437\u043e\u0432\u0430, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u201c\u0437\u0430\u0431\u0440\u0430\u0442\u044c\u201d \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0431\u0443\u0444\u0435\u0440 \u2014 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0443\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439.<\/p>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0432 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0442\u0435\u0440\u044f\u043b\u0430\u0441\u044c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"interfeysy\">\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, wjrpc \u0432\u044b\u0434\u0440\u0430\u043d \u0438\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041f\u0440\u0438\u0447\u0435\u043c, \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441 \u0447\u0438\u0441\u0442\u044b\u043c\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u043d\u043e \u0438 \u043f\u0440\u0435\u0434\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f json-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u043c\u0435\u0442\u043e\u0434, \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0438 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0421\u043c\u044b\u0441\u043b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0441 \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u043b\u0435\u043c, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0441\u043b\u043e\u043c? \u0410 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c (\u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438).<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c, \u0438 \u043a \u0441\u043f\u0438\u0441\u043a\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043b\u0438\u0431\u043e \u0432 \u043e\u0442\u0432\u0435\u0442\u0435, \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0444\u043b\u0430\u0433, \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u043b\u044c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0443\u0436\u043d\u043e \u201c\u043f\u0435\u0440\u0435\u0442\u0440\u044f\u0445\u043d\u0443\u0442\u044c\u201d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0432\u0441\u0435 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 JSON-RPC \u0441\u0435\u0440\u0432\u0438\u0441, \u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0441\u043d\u0443\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043d\u043e \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c. \u0410 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u041f\u0440\u0438\u0447\u0435\u043c, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043c\u0435\u044e\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0442.\u0435. \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. \u0410 \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435\u043f\u0440\u0435\u0434\u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a std::unique_ptr&lt;&gt;.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430, \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">struct icalc {     virtual ~icalc() {}     virtual void plus( request::plus::ptr req, response::plus::callback cb) = 0;     virtual void minus( request::minus::ptr req, response::minus::callback cb) = 0;     virtual void multiplies( request::multiplies::ptr req, response::multiplies::callback cb) = 0;     virtual void divides( request::divides::ptr req, response::divides::callback cb) = 0; };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 typedef-\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u043e. \u041d\u043e \u0432\u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432. \u041d\u0443\u0436\u043d\u043e \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 nullptr, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. \u0415\u0441\u043b\u0438 \u043e\u043d\u0430 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430, \u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0437\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u042d\u0442\u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043b\u0435\u0433\u043a\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">calc1.hpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#pragma once #include &quot;icalc.hpp&quot;  class calc1 : public icalc { public:     virtual void plus( request::plus::ptr req, response::plus::callback cb) override;     virtual void minus( request::minus::ptr req, response::minus::callback cb) override;     virtual void multiplies( request::multiplies::ptr req, response::multiplies::callback cb) override;     virtual void divides( request::divides::ptr req, response::divides::callback cb) override; private:     template&lt;typename Res, typename ReqPtr, typename Callback, typename F&gt;     void impl_( ReqPtr req, Callback cb, F f); };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">calc1.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;calc1.hpp&quot; #include &lt;wjrpc\/memory.hpp&gt;  template&lt;typename Res, typename ReqPtr, typename Callback, typename F&gt; void calc1::impl_( ReqPtr req, Callback cb, F f) {     \/\/ \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435     if ( cb == nullptr )         return;      \/\/ \u043d\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432     if ( req == nullptr )         return cb(nullptr);      auto res = std::make_unique&lt;Res&gt;();     res-&gt;value = f(req-&gt;first,req-&gt;second);     cb( std::move(res) ); }  void calc1::plus( request::plus::ptr req, response::plus::callback cb) {     this-&gt;impl_&lt;response::plus&gt;( std::move(req), cb, [](int f, int s) { return f+s; } ); }  void calc1::minus( request::minus::ptr req, response::minus::callback cb) {     this-&gt;impl_&lt;response::minus&gt;( std::move(req), cb, [](int f, int s) { return f-s; }); }  void calc1::multiplies( request::multiplies::ptr req, response::multiplies::callback cb) {     this-&gt;impl_&lt;response::multiplies&gt;( std::move(req), cb, [](int f, int s) { return f*s; }); }  void calc1::divides( request::divides::ptr req, response::divides::callback cb) {     this-&gt;impl_&lt;response::divides&gt;( std::move(req), cb, [](int f, int s) { return s!=0 ? f\/s : 0; }); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u0432\u0441\u0435 \u0436\u0435 \u043d\u0435 \u043f\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a best practice. \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">calc-&gt;plus( std::move(params), [](response::plus::ptr result) { \u2026 });<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a \u0442\u0435\u043c\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0435\u0449\u0435 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f, \u0430 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u201c\u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0442\u044c\u201d \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u201c\u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c\u201d \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">std::shared_ptr&lt;wjrpc::incoming_holder&gt; ph = std::make_shared&lt;wjrpc::incoming_holder&gt;( std::move(inholder) ); calc-&gt;plus( std::move(params), [ph, &amp;res_list](response::plus::ptr result) {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430     wjrpc::outgoing_result&lt;response::plus&gt; resp;     resp.result = std::move(result);     \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u0437\u043e\u0432\u0430     auto raw_id = ph-&gt;raw_id();     auto call_id = std::make_unique&lt;wjrpc::data_type&gt;( raw_id.first, raw_id.second );     resp.id = std::move(call_id);      \/\/ \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442     typedef wjrpc::outgoing_result_json&lt;response::plus_json&gt; result_json;     typedef wjrpc::outgoing_result_json&lt;response::plus_json&gt; result_json;     \/\/ \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u0443\u0444\u0435\u0440     auto d = ph-&gt;detach();     d-&gt;clear();     result_json::serializer()( resp, std::back_inserter(d) );     res_list.push_back( std::string(d-&gt;begin(), d-&gt;end()) ); });<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422.\u043a. incoming_holder \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u044b\u0439, \u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u201c\u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c\u201d, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 std::shared_ptr. \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0444\u0435\u0440, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u2014 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0440\u043e\u043a. \u0417\u0430\u0445\u0432\u0430\u0442 res_list \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u2014 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0442.\u043a. \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432. \u041d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u043a\u0440\u043e\u043c\u0435 \u0442\u0438\u043f\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 json-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename ResJ&gt; void send_response(std::shared_ptr&lt;wjrpc::incoming_holder&gt; ph, typename ResJ::target::ptr result, std::string&amp; out) {     typedef ResJ result_json;     typedef typename result_json::target result_type;     wjrpc::outgoing_result&lt;result_type&gt; resp;     resp.result = std::move(result);     auto raw_id = ph-&gt;raw_id();     resp.id = std::make_unique&lt;wjrpc::data_type&gt;( raw_id.first, raw_id.second );     typedef wjrpc::outgoing_result_json&lt;result_json&gt; response_json;     typename response_json::serializer()( resp, std::back_inserter( out ) ); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e \u2014 \u044d\u0442\u043e json-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0442\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0442\u0438\u043f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0434 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e JSON-RPC \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0441\u044f<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 plus<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">if ( inholder.method() == &quot;plus&quot; ) {     \/\/ \u0420\u0443\u0447\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430     auto params = inholder.get_params&lt;request::plus_json&gt;(&amp;e);     if ( !e )     {         std::shared_ptr&lt;wjrpc::incoming_holder&gt; ph = std::make_shared&lt;wjrpc::incoming_holder&gt;( std::move(inholder) );         calc-&gt;plus( std::move(params), std::bind( send_response&lt;response::plus_json&gt;, ph, std::placeholders::_1, std::ref(out)) );     }     else     {         make_error&lt;wjrpc::invalid_params&gt;(std::move(inholder), out );     } } \/\/ else if ( inholder.method() == &quot;minus&quot; ) { ... } \/\/ else if ( inholder.method() == &quot;multiplies&quot; ) { .... } \/\/ else if ( inholder.method() == &quot;divides&quot; ) { .... } else {     make_error&lt;wjrpc::procedure_not_found&gt;(std::move(inholder), out ); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043e\u0434 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0434\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430, \u043d\u043e \u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u043d\u0435 \u043c\u0430\u043b\u043e. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u2014 \u0442\u043e\u0436\u0435 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt; typename JParams, typename JResult, void (icalc::*mem_ptr)(     std::unique_ptr&lt;typename JParams::target&gt;,     std::function&lt; void(std::unique_ptr&lt;typename JResult::target&gt;) &gt; ) &gt; void invoke(wjrpc::incoming_holder inholder, std::shared_ptr&lt;icalc&gt; calc, std::string&amp; out) {     typedef JParams params_json;     typedef JResult result_json;     wjson::json_error e;     auto params = inholder.get_params&lt;params_json&gt;(&amp;e);     if ( !e )     {         std::shared_ptr&lt;wjrpc::incoming_holder&gt; ph = std::make_shared&lt;wjrpc::incoming_holder&gt;( std::move(inholder) );         (calc.get()-&gt;*mem_ptr)( std::move(params), std::bind( send_response&lt;result_json&gt;, ph, std::placeholders::_1, std::ref(out) ) );     }     else     {         out = make_error&lt;wjrpc::invalid_params&gt;();     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 wjrpc. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0434 \u0434\u0435\u043c\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0434\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430 (\u0437\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432)<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 \u2018\u0440\u0443\u0447\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439\u2019<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">int main() {     std::vector&lt;std::string&gt; req_list =     {         &quot;{\\&quot;method\\&quot;:\\&quot;plus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;minus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:5, \\&quot;second\\&quot;:10 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;multiplies\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:2 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;divides\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:9, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;     };     std::vector&lt;std::string&gt; res_list;     auto calc = std::make_shared&lt;calc1&gt;();     for ( auto&amp; sreq : req_list )     {         res_list.push_back( std::string() );         std::string&amp; out = res_list.back();         wjrpc::incoming_holder inholder( sreq );         wjson::json_error e;         inholder.parse(&amp;e);         if ( e )         {             out = make_error&lt;wjrpc::parse_error&gt;();         }         else if ( inholder.is_request() )         {             \/\/ \u0415\u0441\u0442\u044c \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u0437\u043e\u0432\u0430             if ( inholder.method() == &quot;plus&quot; )             {                 invoke&lt;request::plus_json, response::plus_json, &amp;icalc::plus&gt;( std::move(inholder), calc, out );             }             else if ( inholder.method() == &quot;minus&quot; )             {                 invoke&lt;request::minus_json, response::minus_json, &amp;icalc::minus&gt;( std::move(inholder), calc, out );             }             else if ( inholder.method() == &quot;multiplies&quot; )             {                 invoke&lt;request::multiplies_json, response::multiplies_json, &amp;icalc::multiplies&gt;( std::move(inholder), calc, out );             }             else if ( inholder.method() == &quot;divides&quot; )             {                 invoke&lt;request::divides_json, response::divides_json, &amp;icalc::divides&gt;( std::move(inholder), calc, out );             }             else             {                 out = make_error&lt;wjrpc::procedure_not_found&gt;();             }         }         else         {             out = make_error&lt;wjrpc::invalid_request&gt;();         }     }      for ( size_t i =0; i != res_list.size(); ++i)     {         std::cout &lt;&lt; req_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; res_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; std::endl;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u043e\u0435 \u043c\u0430\u043d\u0438\u0430\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c run-time \u043e\u0431\u044a\u0435\u043c \u043a\u043e\u0434\u0430 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c\u0438. \u0423\u0431\u0438\u0440\u0430\u044f \u043b\u0438\u0448\u043d\u0438\u0439 <code>if<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043c\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043c \u043a\u043e\u0434\u0430, \u043d\u043e \u0438 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0440\u0430\u0434\u043e\u0441\u0442\u044c \u043d\u0430\u0433\u043e\u0432\u043d\u043e\u043a\u043e\u0434\u0438\u0442\u044c. \u0410 \u0435\u0449\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u043b\u044e\u0431\u044f\u0442 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0438\u0442\u044c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043a\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u044f \u0435\u0433\u043e \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u0430 \u0442\u043e \u0438 \u043f\u0440\u0438\u0432\u043d\u043e\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b. \u041b\u0435\u043d\u044c \u2014 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0435\u043c\u0443 \u043c\u0435\u043d\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u043e \u043d\u0435 \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u0430 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0442\u043e\u043c. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043d\u043e \u0441\u043e \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u2014 \u044d\u0442\u043e \u0436\u0435 \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u044b \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c wjrpc. \u042f \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e wjson, \u043e\u043f\u0438\u0441\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c JSON-RPC \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437\u043d\u0443\u0442\u0440\u0438 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443. \u0410 \u0432\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 wjrpc:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">#include &quot;calc\/calc1.hpp&quot; #include &quot;calc\/api\/plus_json.hpp&quot; #include &quot;calc\/api\/minus_json.hpp&quot; #include &quot;calc\/api\/multiplies_json.hpp&quot; #include &quot;calc\/api\/divides_json.hpp&quot;  #include &lt;wjrpc\/handler.hpp&gt; #include &lt;wjrpc\/method.hpp&gt;  #include &lt;iostream&gt; #include &lt;functional&gt;  JSONRPC_TAG(plus) JSONRPC_TAG(minus) JSONRPC_TAG(multiplies) JSONRPC_TAG(divides)  struct method_list: wjrpc::method_list &lt;     wjrpc::target&lt;icalc&gt;,     wjrpc::invoke_method&lt;_plus_, request::plus_json, response::plus_json, icalc, &amp;icalc::plus&gt;,     wjrpc::invoke_method&lt;_minus_, request::minus_json, response::minus_json, icalc, &amp;icalc::minus&gt;,     wjrpc::invoke_method&lt;_multiplies_, request::multiplies_json, response::multiplies_json, icalc, &amp;icalc::multiplies&gt;,     wjrpc::invoke_method&lt;_divides_, request::divides_json, response::divides_json, icalc, &amp;icalc::divides&gt; &gt;{};  class handler: public wjrpc::handler&lt;method_list&gt; {};  int main() {     std::vector&lt;std::string&gt; req_list =     {         &quot;{\\&quot;method\\&quot;:\\&quot;plus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;minus\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:5, \\&quot;second\\&quot;:10 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;multiplies\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:2, \\&quot;second\\&quot;:2 }, \\&quot;id\\&quot; :1 }&quot;,         &quot;{\\&quot;method\\&quot;:\\&quot;divides\\&quot;, \\&quot;params\\&quot;:{ \\&quot;first\\&quot;:9, \\&quot;second\\&quot;:3 }, \\&quot;id\\&quot; :1 }&quot;     };     std::vector&lt;std::string&gt; res_list;      auto calc = std::make_shared&lt;calc1&gt;();     handler h;     handler::options_type opt;     opt.target = calc;     h.start(opt, 1);      for ( auto&amp; sreq : req_list )     {         h.perform( sreq, [&amp;res_list](std::string out) { res_list.push_back(out);} );     }      for ( size_t i =0; i != res_list.size(); ++i)     {         std::cout &lt;&lt; req_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; res_list[i] &lt;&lt; std::endl;         std::cout &lt;&lt; std::endl;     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JSONRPC_TAG \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e JSON<em>NAME \u0432 wjson, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 n<\/em>, \u043e\u0431\u0440\u0430\u043c\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e wjrpc::method_list \u0438 wjrpc::invoke_method \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a wjrpc::handler. \u041d\u0430\u0440\u044f\u0434\u0443 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0431\u044b\u043b \u043e\u043f\u0438\u0441\u0430\u043d \u0442\u0438\u043f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f perform_io, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 wjrpc::data_ptr.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">typedef std::vector&lt;char&gt; data_type; typedef std::unique_ptr&lt;data_type&gt; data_ptr; typedef std::function&lt; void(data_ptr) &gt; output_handler_t;  void perform_io(data_ptr d, output_handler_t handler) { \u2026 } void perform(std::string str, std::function&lt;void(std::string)&gt; handler) {     auto d = std::make_unique&lt;data_type&gt;( str.begin(), str.end() );     this-&gt;perform_io( std::move(d), [handler](data_ptr d)     {         handler( std::string(d-&gt;begin(), d-&gt;end()) );     }); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443, \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">struct plus_handler {     template&lt;typename T&gt;     void operator()(T&amp; t, request::plus::ptr req)     { \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f         t.target()-&gt;plus( std::move(req), nullptr );     }      template&lt;typename T, typename Handler&gt;     void operator()(T&amp; t, request::plus::ptr req, Handler handler)     {         \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430         t.target()-&gt;plus( std::move(req), [handler](response::plus::ptr res)         {             if ( res != nullptr )                 handler( std::move(res), nullptr );             else                 handler( nullptr, std::make_unique&lt;wjrpc::service_unavailable&gt;() );         });     } };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0438\u043b\u0438 \u0442\u0430\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">struct plus_handler {     template&lt;typename T&gt;     void operator()(T&amp;, request::plus::ptr req)     {     }      template&lt;typename T, typename Handler&gt;     void operator()(T&amp;, request::plus::ptr req, Handler handler)     {         if (req==nullptr)         {             handler( nullptr, std::make_unique&lt;wjrpc::invalid_params&gt;() );             return;         }         auto res = std::make_unique&lt;response::plus&gt;();         res-&gt;value = req-&gt;first + req-&gt;second;         handler( std::move(res), nullptr );     } };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c handler \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0442\u0432\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u0432\u0435\u0442, \u0430 \u0432\u0442\u043e\u0440\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435. \u0410 t \u2014 \u044d\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 JSON-RPC-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 (\u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 self \u0432 python). \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">struct method_list: wjrpc::method_list &lt;     wjrpc::target&lt;icalc&gt;,     wjrpc::method&lt; wjrpc::name&lt;_plus_&gt;, wjrpc::invoke&lt;request::plus_json, response::plus_json, plus_handler&gt; &gt;,     wjrpc::invoke_method&lt;_minus_, request::minus_json, response::minus_json, icalc, &amp;icalc::minus&gt;,     wjrpc::invoke_method&lt;_multiplies_, request::multiplies_json, response::multiplies_json, icalc, &amp;icalc::multiplies&gt;,     wjrpc::invoke_method&lt;_divides_, request::divides_json, response::divides_json, icalc, &amp;icalc::divides&gt; &gt;{};<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, invoke_method&lt;&gt; \u044d\u0442\u043e \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f wjrpc::method&lt;&gt;, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">mem_fun_handler<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;     typename Params,     typename Result,     typename I,     void (I::*mem_ptr)(         std::unique_ptr&lt;Params&gt;,         std::function&lt; void(std::unique_ptr&lt;Result&gt;) &gt;     ) &gt; struct mem_fun_handler {     typedef std::unique_ptr&lt;Params&gt; request_ptr;     typedef std::unique_ptr&lt;Result&gt; responce_ptr;     typedef std::unique_ptr&lt; error&gt; json_error_ptr;      typedef std::function&lt; void(responce_ptr, json_error_ptr) &gt; jsonrpc_callback;      template&lt;typename T&gt;     void operator()(T&amp; t, request_ptr req) const;      template&lt;typename T&gt;     void operator()(T&amp; t, request_ptr req, jsonrpc_callback cb) const; };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041c\u044b \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0434\u0430 \u0438 \u0441\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f JSON-RPC \u0431\u044b\u043b\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0449\u0435, \u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0442\u0430\u043a\u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u0435\u0441\u0442\u044c (\u0430 \u0432\u0435\u0434\u044c \u043c\u043e\u0436\u043d\u043e \u0438 \u0431\u0435\u0437 \u043d\u0438\u0445), \u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0447\u0430\u0441\u0442\u043e (\u0434\u0430 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430) \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438. \u0410\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c. \u041d\u0435 \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0438\u043b \u043e\u0442\u043a\u0443\u0434\u0430-\u0442\u043e \u043a\u043e\u0434, \u043b\u0435\u043d\u044c \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043d\u0430 \u044d\u0442\u0430\u043f\u0430\u0445 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043d\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430. \u0422\u0430\u043a \u0437\u0430\u0447\u0435\u043c \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u043f\u0440? \u041f\u0430\u0440\u0443-\u0442\u0440\u043e\u0439\u043a\u0443 \u0441\u0438\u043d\u0433\u043b\u0435\u0442\u043e\u043d\u043e\u0432 \u0438 \u0432\u043f\u0435\u043d\u0434\u044e\u0440\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u044f\u043c\u043e \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u0440\u043e\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c. \u041f\u043e\u0442\u043e\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u043a\u043e\u0434\u043e\u043c \u0438 \u043f\u043e\u0442\u0438\u0445\u043e\u043d\u044c\u043a\u0443 \u0432\u0441\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f, \u0438 \u043e\u043d \u0443\u0435\u0437\u0436\u0430\u0435\u0442 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u0442\u044f\u0436\u0435\u043b\u043e, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u043f\u0440\u043e\u0449\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f, \u0447\u0435\u043c \u043e\u0442\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u201c\u043e\u0431\u044f\u0437\u0430\u0442\u044c\u201d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0442\u0438\u043f\u0430 wjrpc::invoke_method. \u041d\u0430 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u0432\u0435\u0441\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e JSON-RPC. \u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u201c\u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430\u201d \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443 \u0432 \u0441\u043b\u043e\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0442\u0438\u043f\u0430 wjrpc::invoke_method.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">struct icalc {     virtual ~icalc() {}     virtual request::plus::ptr plus( request::plus::ptr req) = 0;     virtual request::minus::ptr minus( request::minus::ptr req) = 0;     virtual request::multiplies::ptr multiplies( request::multiplies::ptr req) = 0;     virtual request::divides::ptr divides( request::divides::ptr req) = 0; };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 wjrpc::handler&lt;&gt; \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438. \u0415\u0441\u043b\u0438 callback, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0443\u0436\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u0443 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">calc-&gt;plus( std::move(req), [this](response::plus::ptr) {} );<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418 \u0442\u0430\u043a \u0442\u043e\u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">std::shared_ptr&lt;calc&gt; pthis = this-&gt;shared_from_this(); calc-&gt;plus( std::move(req), [pthis](response::plus::ptr) {} );<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u0442.\u043a. \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u0445\u0432\u0430\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438. \u0412\u0430\u0440\u0438\u0430\u043d\u0442<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">std::weak_ptr&lt;calc&gt; wthis = this-&gt;shared_from_this(); calc-&gt;plus( std::move(req), [wthis](response::plus::ptr) {     if ( auto pthis = wthis.lock() )     {         \/* \u2026 *\/     } } );<\/code><\/pre>\n<p>  <\/p>\n<p>\u0443\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u0443\u043b\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432). \u0414\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0433\u0443\u043b\u044f\u0442\u044c \u043f\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435 callback-\u0438 \u0441\u0442\u0430\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">std::weak_ptr&lt;int&gt; w = this-&gt;_p; \/* _p = std::shared_ptr&lt;int&gt;(1);*\/ std::weak_ptr&lt;calc&gt; wthis = this-&gt;shared_from_this(); calc-&gt;plus( std::move(req), [wthis, w](response::plus::ptr) {     if ( auto pthis = wthis.lock() )     {         if ( nullptr == w.lock() )             return;         \/* \u2026 *\/     } } );<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u043d\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b (\u043d\u0435\u0442 \u0432 wjrpc)<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">callback-\u043e\u0431\u0435\u0440\u0442\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt;typename H&gt; class owner_handler { public:     typedef std::weak_ptr&lt;int&gt; weak_type;     owner_handler() = default;      owner_handler(H&amp;&amp; h, weak_type alive)         : _handler( std::forward&lt;H&gt;(h) )         , _alive(alive)     { }      template &lt;class... Args&gt;     auto operator()(Args&amp;&amp;... args)         -&gt; typename std::result_of&lt; H(Args&amp;&amp;...) &gt;::type     {         if ( auto p = _alive.lock() )         {             return _handler( std::forward&lt;Args&gt;(args)... );         }         return typename std::result_of&lt; H(Args&amp;&amp;...) &gt;::type();     } private:     H _handler;     weak_type _alive; };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 (\u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">class owner { public:     typedef std::shared_ptr&lt;int&gt; alive_type;     typedef std::weak_ptr&lt;int&gt; weak_type;      owner()         : _alive( std::make_shared&lt;int&gt;(1) )     { }      owner(const owner&amp; ) = delete;     owner&amp; operator = (const owner&amp; ) = delete;      owner(owner&amp;&amp; ) = default;     owner&amp; operator = (owner&amp;&amp; ) = default;      alive_type&amp; alive() { return _alive; }     const alive_type&amp; alive() const { return _alive; }     void reset() { _alive = std::make_shared&lt;int&gt;(*_alive + 1); }      template&lt;typename Handler&gt;     owner_handler&lt;typename std::remove_reference&lt;Handler&gt;::type&gt;     wrap(Handler&amp;&amp; h) const     {         return         owner_handler&lt;         typename std::remove_reference&lt;Handler&gt;::type         &gt;(             std::forward&lt;Handler&gt;(h),           std::weak_ptr&lt;int&gt;(_alive)         );     } private:     mutable alive_type _alive; };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/\/ owner - \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 std::weak_ptr&lt;calc&gt; wthis = this-&gt;shared_from_this(); calc-&gt;plus( std::move(req), this-&gt;wrap([wthis](response::plus::ptr) {     if ( auto pthis = wthis.lock() )     {         \/* \u2026 *\/     } })); \/\/ \u2026 \/\/ \u0421\u0431\u0440\u043e\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 owner::reset(); \/\/ \u043d\u0435\u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 callback-\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. \u041e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u044d\u0442\u043e \u0432 \u0432\u0438\u0434\u0443. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432\u044b\u0440\u0432\u0430\u043d\u0430 \u0438\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u0438 \u0442\u0430\u043c \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0440\u0435\u0448\u0435\u043d\u044b. \u0421\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u043d\u0435\u0442 \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0430\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"json-rpc-engine\">JSON-RPC Engine<\/h2>\n<p>  <\/p>\n<p>\u0414\u0432\u0438\u0436\u043e\u043a wjrpc::engine \u2013 \u044d\u0442\u043e, \u043f\u043e \u0441\u0443\u0442\u0438, \u0440\u0435\u0435\u0441\u0442\u0440 jsonrpc-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u043c\u0438, \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0438\u043c\u0435\u043d \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 wjrpc::engine. \u0422\u0430\u043a\u0436\u0435 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c. \u0414\u043b\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f callback-\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0433\u0443\u043b\u044f\u0442\u044c \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e \u0434\u043e\u043b\u0433\u043e \u043f\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u041d\u043e \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0443\u0436\u0435\u043d wjrpc::engine, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0432\u0448\u0443\u044e \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043f\u0440\u0438\u0434\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 icalc. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0437\u043b\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u043a\u0441\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0435\u043d\u044f\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 plus, \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044f \u0438\u0445.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">calc\/calc_p.hpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#pragma once #include &quot;icalc.hpp&quot;  class calc_p     : public icalc { public:     void initialize(std::shared_ptr&lt;icalc&gt;);     virtual void plus( request::plus::ptr req, response::plus::callback cb) override;     virtual void minus( request::minus::ptr req, response::minus::callback cb) override;     virtual void multiplies( request::multiplies::ptr req, response::multiplies::callback cb) override;     virtual void divides( request::divides::ptr req, response::divides::callback cb) override; private:     template&lt;typename ReqPtr, typename Callback&gt;     bool check_( ReqPtr&amp; req, Callback&amp; cb);     std::shared_ptr&lt;icalc&gt; _next; };<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">calc\/calc_p.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;calc_p.hpp&quot; #include &lt;memory&gt;  void calc_p::initialize(std::shared_ptr&lt;icalc&gt; next) {     _next = next; }  void calc_p::plus( request::plus::ptr req, response::plus::callback cb) {     if ( !this-&gt;check_(req, cb))         return;     req-&gt;first++;     req-&gt;second++;     _next-&gt;plus(std::move(req), [cb](response::plus::ptr res)     {         res-&gt;value++;         cb(std::move(res) );     }); }  void calc_p::minus( request::minus::ptr req, response::minus::callback cb) {     if ( this-&gt;check_(req, cb))         _next-&gt;minus(std::move(req), std::move(cb) ); }  void calc_p::multiplies( request::multiplies::ptr req, response::multiplies::callback cb) {     if ( this-&gt;check_(req, cb))         _next-&gt;multiplies(std::move(req), std::move(cb) ); }  void calc_p::divides( request::divides::ptr req, response::divides::callback cb) {     if ( this-&gt;check_(req, cb))         _next-&gt;divides(std::move(req), std::move(cb) ); }  template&lt;typename ReqPtr, typename Callback&gt; bool calc_p::check_( ReqPtr&amp; req, Callback&amp; cb) {     if ( cb==nullptr )         return false;     if ( req != nullptr )         return true;     cb(nullptr);     return false; }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043f\u0440\u043e\u043a\u0441\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 icalc, \u043a\u0443\u0434\u0430 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u0430\u043a \u0435\u0441\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 plus, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0435\u0433\u043e \u201c\u0437\u043b\u043e\u0431\u043d\u043e\u0441\u0442\u044c\u201d. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0438 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u043e\u043a\u0441\u0438 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441: \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0438\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e, \u043a\u0430\u043a \u043f\u0440\u0438\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0442, \u0442\u043e\u0433\u0434\u0430 \u043e\u043d \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u0438 \u0437\u043b\u043e\u0431\u043d\u044b\u0435 \u0434\u0435\u043b\u0430. \u0417\u0430\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0438\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0446\u0435\u043b\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u043a\u0441\u0438, \u0438\u043b\u0438 \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0438\u0448\u0435\u043c JSON-RPC \u0448\u043b\u044e\u0437.<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">JSONRPC_TAG(plus) JSONRPC_TAG(minus) JSONRPC_TAG(multiplies) JSONRPC_TAG(divides)  struct method_list: wjrpc::method_list &lt;     wjrpc::call_method&lt;_plus_, request::plus_json, response::plus_json&gt;,     wjrpc::call_method&lt;_minus_, request::minus_json, response::minus_json&gt;,     wjrpc::call_method&lt;_multiplies_, request::multiplies_json, response::multiplies_json&gt;,     wjrpc::call_method&lt;_divides_, request::divides_json, response::divides_json, icalc&gt; &gt; {};<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0432\u0435\u0434\u044c \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c JSON-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432. \u041d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u2014 \u0432 \u043d\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 icalc:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">class handler : public ::wjrpc::handler&lt;method_list&gt; , public icalc { public:     virtual void plus( request::plus::ptr req, response::plus::callback cb) override     {         this-&gt;template call&lt;_plus_&gt;( std::move(req), cb, nullptr );     }      virtual void minus( request::minus::ptr req, response::minus::callback cb) override     {         this-&gt;template call&lt;_minus_&gt;( std::move(req), cb, nullptr );     }      virtual void multiplies( request::multiplies::ptr req, response::multiplies::callback cb) override     {         this-&gt;template call&lt;_multiplies_&gt;( std::move(req), cb, nullptr );     }      virtual void divides( request::divides::ptr req, response::divides::callback cb) override     {         this-&gt;template call&lt;_divides_&gt;( std::move(req), cb, nullptr );     } };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u0430 \u2014 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 call&lt;&gt; \u0441 \u0442\u0435\u0433\u043e\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0442\u0432\u0435\u0442\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043e\u0441\u044f\u0434\u0435\u0442 \u0432 \u0434\u0432\u0438\u0436\u043a\u0435 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u0435\u043c\u0443 \u043e\u0442\u0432\u0435\u0442. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438, \u043f\u043e \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d callback \u0441 nullptr.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u0440\u0438\u0448\u043b\u0430 JSON-RPC \u043e\u0448\u0438\u0431\u043a\u0430, \u0442\u043e \u0432 callback \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d nullptr, \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439. \u041f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0442\u0430\u0449\u0438\u0442\u044c JSON-RPC \u043a\u043e\u0434\u044b \u0432 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0438\u0434\u0435\u044f. \u041b\u0443\u0447\u0448\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430\u043c\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0448\u043b\u044e\u0437, \u0441\u0435\u0440\u0432\u0438\u0441, \u043f\u0440\u043e\u043a\u0441\u0438 \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/261\/d79\/e2b\/261d79e2bc4a4c91a7a3c3620a0a06af.png\"\/>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448 \u043f\u0440\u043e\u043a\u0441\u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u043c, \u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043d\u0430\u043c \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0432\u0430\u0436\u043d\u043e. \u041f\u0440\u043e\u043a\u0441\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0448\u043b\u044e\u0437\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u0441 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0441\u0432\u044f\u0437\u0430\u043d \u043f\u0440\u043e\u043a\u0441\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u043a\u0441\u0438, \u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0446\u0435\u043b\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u0417\u0430\u0434\u0430\u0447\u0430 \u0448\u043b\u044e\u0437\u0430 \u2014 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e \u0441\u0435\u0442\u0438. \u041d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0435\u0433\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0433\u043e \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u043a\u0441\u0438. <\/p>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u043a\u0441\u0438 \u0442\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u0438 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0443. \u041a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u0435\u0433\u043e \u0447\u0435\u0441\u0442\u043d\u043e \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 callback, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u043a\u0441\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 callback, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0448\u0435\u043b \u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442. \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f JSON-RPC \u0434\u0432\u0438\u0436\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u043e id \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 JSON-RPC \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e. \u0412 \u043d\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f callback \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u043a\u0441\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0442\u0432\u0435\u0442 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0448 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 callback, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">calc\/calc_p.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;calc\/calc1.hpp&quot; #include &quot;calc\/calc_p.hpp&quot; #include &quot;calc\/api\/plus_json.hpp&quot; #include &quot;calc\/api\/minus_json.hpp&quot; #include &quot;calc\/api\/multiplies_json.hpp&quot; #include &quot;calc\/api\/divides_json.hpp&quot;  #include &lt;wjrpc\/engine.hpp&gt; #include &lt;wjrpc\/handler.hpp&gt; #include &lt;wjrpc\/method.hpp&gt;  #include &lt;iostream&gt; #include &lt;functional&gt;  namespace service {     JSONRPC_TAG(plus)     JSONRPC_TAG(minus)     JSONRPC_TAG(multiplies)     JSONRPC_TAG(divides)      struct method_list: wjrpc::method_list     &lt;     wjrpc::target&lt;icalc&gt;,     wjrpc::invoke_method&lt;_plus_, request::plus_json, response::plus_json, icalc, &amp;icalc::plus&gt;,     wjrpc::invoke_method&lt;_minus_, request::minus_json, response::minus_json, icalc, &amp;icalc::minus&gt;,     wjrpc::invoke_method&lt;_multiplies_, request::multiplies_json, response::multiplies_json, icalc, &amp;icalc::multiplies&gt;,     wjrpc::invoke_method&lt;_divides_, request::divides_json, response::divides_json, icalc, &amp;icalc::divides&gt;     &gt;{};      class handler: public ::wjrpc::handler&lt;method_list&gt; {};      typedef wjrpc::engine&lt;handler&gt; engine_type; }  namespace gateway {     JSONRPC_TAG(plus)     JSONRPC_TAG(minus)     JSONRPC_TAG(multiplies)     JSONRPC_TAG(divides)      struct method_list: wjrpc::method_list     &lt;     wjrpc::call_method&lt;_plus_, request::plus_json, response::plus_json&gt;,     wjrpc::call_method&lt;_minus_, request::minus_json, response::minus_json&gt;,     wjrpc::call_method&lt;_multiplies_, request::multiplies_json, response::multiplies_json&gt;,     wjrpc::call_method&lt;_divides_, request::divides_json, response::divides_json&gt;     &gt;     {};      class handler     : public ::wjrpc::handler&lt;method_list&gt;     , public icalc     {     public:         virtual void plus( request::plus::ptr req, response::plus::callback cb) override         {             this-&gt;template call&lt;_plus_&gt;( std::move(req), cb, nullptr );         }          virtual void minus( request::minus::ptr req, response::minus::callback cb) override         {             this-&gt;template call&lt;_minus_&gt;( std::move(req), cb, nullptr );         }          virtual void multiplies( request::multiplies::ptr req, response::multiplies::callback cb) override         {             this-&gt;template call&lt;_multiplies_&gt;( std::move(req), cb, nullptr );         }          virtual void divides( request::divides::ptr req, response::divides::callback cb) override         {             this-&gt;template call&lt;_divides_&gt;( std::move(req), cb, nullptr );         }     };      typedef wjrpc::engine&lt;handler&gt; engine_type; }  int main() {     \/\/ \u041f\u0440\u043e\u043a\u0441\u0438 N1     auto prx1 = std::make_shared&lt;calc_p&gt;();     \/\/ \u0428\u043b\u044e\u0437     auto gtw = std::make_shared&lt;gateway::engine_type&gt;();     \/\/ \u0421\u0435\u0440\u0432\u0438\u0441     auto srv = std::make_shared&lt;service::engine_type&gt;();     \/\/ \u041f\u0440\u043e\u043a\u0441\u0438 N2     auto prx2 = std::make_shared&lt;calc_p&gt;();     \/\/ \u041a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440     auto clc = std::make_shared&lt;calc1&gt;();     \/\/ \u0421\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u043a\u0441\u0438 \u0441 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u043c     prx2-&gt;initialize(clc);     \/\/ \u0421\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u043e\u043a\u0441\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441     service::engine_type::options_type srv_opt;     srv_opt.target = prx2;     srv-&gt;start(srv_opt, 11);      \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0448\u043b\u044e\u0437     gateway::engine_type::options_type cli_opt;     gtw-&gt;start(cli_opt, 22);      \/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0448\u043b\u044e\u0437\u0430 \u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0441 \u0441\u0435\u0440\u0438\u0432\u0438\u0441\u043e\u043c     gtw-&gt;reg_io(33, [srv]( wjrpc::data_ptr d, wjrpc::io_id_t \/*io_id*\/, wjrpc::output_handler_t handler)     {         std::cout &lt;&lt; &quot; REQUEST: &quot; &lt;&lt; std::string( d-&gt;begin(), d-&gt;end() ) &lt;&lt; std::endl;         srv-&gt;perform_io(std::move(d), 44, [handler](wjrpc::data_ptr d)         {             \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 JSON-RPC \u043e\u0442\u0432\u0435\u0442\u0430             std::cout &lt;&lt; &quot; RESPONSE: &quot; &lt;&lt; std::string( d-&gt;begin(), d-&gt;end() ) &lt;&lt; std::endl;             handler(std::move(d) );         });     });     \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0448\u043b\u044e\u0437\u0430 \u043f\u043e \u0435\u0433\u043e ID     auto gtwh = gtw-&gt;find(33);     \/\/ \u0421\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0448\u043b\u044e\u0437\u0430 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0440\u043e\u043a\u0441\u0438     prx1-&gt;initialize(gtwh);     \/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c plus \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043a\u0441\u0438 (prx1-&gt;gtw-&gt;srv-&gt;prx2-&gt;clc)     auto plus = std::make_unique&lt;request::plus&gt;();     plus-&gt;first = 1;     plus-&gt;second = 2;     prx1-&gt;plus( std::move(plus), [](response::plus::ptr res)     {         std::cout &lt;&lt; &quot;1+2=&quot; &lt;&lt; res-&gt;value &lt;&lt; std::endl;;     });      \/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c plus \u0447\u0435\u0440\u0435\u0437 \u0448\u043b\u044e\u0437 (gtw-&gt;srv-&gt;prx2-&gt;clc)     auto minus = std::make_unique&lt;request::minus&gt;();     minus-&gt;first = 4;     minus-&gt;second = 3;     gtwh-&gt;minus( std::move(minus), [](response::minus::ptr res)     {         std::cout &lt;&lt; &quot;4-3=&quot; &lt;&lt; res-&gt;value &lt;&lt; std::endl;;     }); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">REQUEST: {&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;method&quot;:&quot;plus&quot;,&quot;params&quot;:{&quot;first&quot;:2,&quot;second&quot;:3},&quot;id&quot;:1} RESPONSE: {&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;result&quot;:{&quot;value&quot;:8},&quot;id&quot;:1} 1+2=9 REQUEST: {&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;method&quot;:&quot;minus&quot;,&quot;params&quot;:{&quot;first&quot;:4,&quot;second&quot;:3},&quot;id&quot;:2} RESPONSE: {&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;result&quot;:{&quot;value&quot;:1},&quot;id&quot;:2} 4-3=1<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u043a\u0441\u0438 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 JSON-RPC \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 2 \u0438 3 \u0432\u043c\u0435\u0441\u0442\u043e 1 \u0438 2. \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u043a\u0441\u0438 \u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 8. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u043a\u0441\u0438 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 9. \u0412\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0448\u043b\u044e\u0437, \u043c\u0438\u043d\u0443\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u043a\u0441\u0438, \u043d\u043e \u043e\u043d \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0432\u0442\u043e\u0440\u043e\u0439, \u0430 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043b\u044f munus \u0442\u0430\u043c \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u0434\u0432\u0443\u0437\u043d\u0430\u0447\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u2014 \u044d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">create_id<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">inline wjrpc::io_id_t create_id() {   static std::atomic&lt;wjrpc::io_id_t&gt; counter( (wjrpc::io_id_t(1)) );   return counter.fetch_add(1); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0443\u0436\u0430\u0442 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043d\u0438\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">  gtw-&gt;reg_io(33, []( wjrpc::data_ptr, wjrpc::io_id_t, wjrpc::output_handler_t)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0432 JSON-RPC \u0434\u0432\u0438\u0436\u043a\u0435 \u0448\u043b\u044e\u0437\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c, \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c, \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0436\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u041d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441. \u0410 \u0447\u0438\u0441\u043b\u043e 44 \u2014 \u044d\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0435\u043a\u043e\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0422\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 service::engine_type, \u043d\u043e \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (\u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0430 \u0442\u0430\u043a\u043e\u0435 \u0432 wjrpc \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c), \u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0439\u043f\u044b(::pipe), \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c, \u043d\u043e \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u044f \u0432\u0430\u0441 \u0435\u0449\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u043f\u0443\u0442\u0430\u044e, \u0434\u0430 \u0438 \u043e\u0441\u043e\u0431\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u044d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0432\u0443\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u044e\u0430\u043d\u0441\u0430\u043c\u0438 \u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u043e\u0431\u0432\u044f\u0437\u043a\u0438, \u043a \u0442\u0435\u043c\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u044e\u0449\u0435\u0439. \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0439\u043f\u044b \u0435\u0441\u0442\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 examples \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0438 \u043a\u043e\u0434 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 wjson, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0442\u043e \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 wjrpc::incoming_holder \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 JSON-RPC \u0441\u0435\u0440\u0432\u0435\u0440. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0442\u043e\u0440\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e wjrpc::handler \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c run-time \u043a\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/mambaru\/wjrpc\">wjrpc<\/a> \u043c\u043e\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c. \u0412\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f <a href=\"https:\/\/github.com\/migashko\/faslib\">faslib<\/a> \u0438 <a href=\"https:\/\/github.com\/mambaru\/wjson\">wjson<\/a>. \u0427\u0442\u043e\u0431\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0442\u0435\u0441\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">git clone https:\/\/github.com\/migashko\/faslib.git git clone https:\/\/github.com\/mambaru\/wjson.git git clone https:\/\/github.com\/mambaru\/wjrpc.git  # \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 wjrpc cd faslib mkdir build cd build cmake ..  # \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0442\u0435\u0441\u0442\u044b cd ..\/..\/wjrpc mkdir build cd build cmake -DWJRPC_BUILD_ALL=ON .. make<\/code><\/pre>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/312994\/\"> https:\/\/habrahabr.ru\/post\/312994\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habrahabr.ru\/post\/311262\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043f\u0440\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 JSON-\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 C++ \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u0442.\u043a. \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043d\u043e \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.\u041a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u2014 \u0435\u0441\u043b\u0438 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0442\u043e \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u0438 \u0432 wjrpc, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 wjrpc \u201c\u0432\u044b\u0434\u0440\u0430\u043d\u201d \u0438\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u043f\u043e\u0434 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u0431\u044b\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d, \u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-279957","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279957"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279957\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}