{"id":199082,"date":"2013-10-31T00:57:06","date_gmt":"2013-10-30T20:57:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=199082"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=199082","title":{"rendered":"<span class=\"post_title\">YATE. \u041e \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0441 \u0412\u0430\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c YATE \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430 python.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/3bb\/725\/efc\/3bb725efc630837682501bb00dc25991.png\"\/> <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0412\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/h4>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u044c Yate \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0430\u0448\u0438\u043c \u0431\u0443\u0434\u0443\u0449\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b exmodule.conf \u0438 \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<br \/>  <code>[listener test]<\/code><br \/>  <code>type=tcp<\/code><br \/>  <code>addr=127.0.0.1<\/code><br \/>  <code>port=5678<\/code><br \/>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430\u0447\u043d\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 5678 \u043f\u043e tcp \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c!<br \/>  <code>telnet 0 5678<\/code><br \/>  <code>Trying 0.0.0.0...<\/code><br \/>  <code>Connected to 0.<\/code><br \/>  <code>Escape character is '^]'.<\/code><br \/>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443.<\/p>\n<h4>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b<\/h4>\n<p>  <\/p>\n<h6>\u0424\u043e\u0440\u043c\u0430\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/h6>\n<p>&lt;\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b&gt; \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<br \/>  [\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b] \u2014 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0441\u0442\u0440\u043e\u043a\u0438 (\\n, ^J, decimal 10). \u0421\u0438\u043c\u0432\u043e\u043b\u044b, ASCII-\u043a\u043e\u0434\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u043d\u044c\u0448\u0435 32, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0438\u043c\u0432\u043e\u043b &quot;%&quot; \u0438 &quot;:&quot; \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u044b \u0432 %, \u0433\u0434\u0435  \u2014 \u0441\u0438\u043c\u0432\u043e\u043b \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0440\u0430\u0432\u043d\u044b\u043c 64 + ASCII-\u043a\u043e\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u0430.<br \/>  \u0421\u0438\u043c\u0432\u043e\u043b &quot;%&quot; \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d \u0432 &quot;%%&quot;, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u043c \u0441\u043b\u043e\u0432\u0435. \u0421\u0438\u043c\u0432\u043e\u043b &quot;:&quot; \u043d\u0435 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<h6>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/h6>\n<p>\u041f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u044c\u044e \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f. <\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&gt;connect<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b><code> %%&gt;connect:&lt;role&gt;[:&lt;id&gt;][:&lt;type&gt;]<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u043e\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<br \/>  \u0421\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435. \u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0440\u043e\u043b\u044f\u043c\u0438 play, record \u0438\u043b\u0438 playrec \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u044b \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043a\u0430\u043d\u0430\u043b\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. <br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;role&gt;<\/code> \u2014 \u0440\u043e\u043b\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f: global, channel, play, record, playrec<br \/>  <code>&lt;id&gt;<\/code> \u2014 id \u043a\u0430\u043d\u0430\u043b\u0430 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u0441\u043e\u043a\u0435\u0442<br \/>  <code>&lt;type&gt;<\/code> \u2014 \u0442\u0438\u043f \u043a\u0430\u043d\u0430\u043b\u0430<\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&gt;install<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&gt;install:[&lt;priority&gt;]:&lt;name&gt;[:&lt;filter-name&gt;[:&lt;filter-value&gt;]]<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (\u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432). \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e.<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;priority&gt;<\/code> \u2014 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442. \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 100<br \/>  <code>&lt;name&gt;<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 (\u0441\u0438\u0433\u043d\u0430\u043b\u0430), \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d<br \/>  <code>&lt;filter-name&gt;<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043e\u0439 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430<br \/>  <code>&lt;filter-value&gt;<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043e\u0439 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430<\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&lt;install<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&lt;install:&lt;priority&gt;:&lt;name&gt;:&lt;success&gt;<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;priority&gt;<\/code> \u2014 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<br \/>  <code>&lt;name&gt;<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d<br \/>  <code>&lt;success&gt;<\/code> \u2014 boolean (\u00abtrue\u00bb or \u00abfalse\u00bb)<\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&gt;uninstall<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&gt;uninstall:&lt;name&gt;<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;name&gt;<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d<\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&lt;uninstall<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&lt;uninstall:&lt;priority&gt;:&lt;name&gt;:&lt;success&gt;<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0435\u043d<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;priority&gt;<\/code> \u2014 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<br \/>  <code>&lt;name&gt;<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d<br \/>  <code>&lt;success&gt;<\/code> \u2014 boolean (\u00abtrue\u00bb or \u00abfalse\u00bb)<\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&gt;message<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&gt;message:&lt;id&gt;:&lt;time&gt;:&lt;name&gt;:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 Yate, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043e\u0442\u0432\u0435\u0442.<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;id&gt;<\/code> \u2014 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 ID \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Yate-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c<br \/>  <code>&lt;time&gt;<\/code> \u2014 timestamp, \u043a\u043e\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435<br \/>  <code>&lt;name&gt;<\/code> \u2014 \u0438\u043c\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f (\u0441\u0438\u0433\u043d\u0430\u043b\u0430)<br \/>  <code>&lt;retvalue&gt;<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<br \/>  <code>&lt;key&gt;=&lt;value&gt;<\/code> \u2014 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&lt;message<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&lt;message:&lt;id&gt;:&lt;processed&gt;:[&lt;name&gt;]:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 %%&gt;message. \u041a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442, \u043e\u043d \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0435\u0435.<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;id&gt;<\/code> \u2014 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 ID \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443<br \/>  <code>&lt;processed&gt;<\/code> \u2014 boolean. \u00abtrue\u00bb \u2014 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u00abfalse\u00bb \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c<br \/>  <code>&lt;name&gt;<\/code> \u2014 \u0438\u043c\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<br \/>  <code>&lt;retvalue&gt;<\/code> \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<br \/>  <code>&lt;key&gt;=&lt;value&gt;<\/code> \u2014 \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435; \u0447\u0442\u043e \u0431\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u044e\u0447 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f ()<\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&gt;message<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&gt;message:&lt;id&gt;:&lt;time&gt;:&lt;name&gt;:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u0417\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e.<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;id&gt;<\/code> \u2014 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 ID \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c<br \/>  <code>&lt;time&gt;<\/code> \u2014 timestamp, \u043a\u043e\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435<br \/>  <code>&lt;name&gt;<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f (\u0441\u0438\u0433\u043d\u0430\u043b\u0430)<br \/>  <code>&lt;retvalue&gt;<\/code> \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<br \/>  <code>&lt;key&gt;=&lt;value&gt;<\/code> \u2014 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <\/p>\n<p>  <b><i>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e:<\/i><\/b> <code>%%&lt;message<\/code><br \/>  <b><i>\u0424\u043e\u0440\u043c\u0430\u0442:<\/i><\/b> <code>%%&lt;message:&lt;id&gt;:&lt;processed&gt;:[&lt;name&gt;]:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]<\/code><br \/>  <b><i>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/i><\/b> \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e<br \/>  <b><i>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/i><\/b> \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 %%&gt;message. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<br \/>  <b><i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/i><\/b><br \/>  <code>&lt;id&gt;<\/code> \u2014 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 ID \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443<br \/>  <code>&lt;processed&gt;<\/code> \u2014 boolean. \u00abtrue\u00bb \u2014 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u00abfalse\u00bb \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c<br \/>  <code>&lt;name&gt;<\/code> \u2014 \u0438\u043c\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<br \/>  <code>&lt;retvalue&gt;<\/code> \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<br \/>  <code>&lt;key&gt;=&lt;value&gt;<\/code> \u2014 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<h4>\u041f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c<\/h4>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0432 \u0433\u043b\u0430\u0437\u0430 \u043a\u0438\u043d\u0443\u043b\u0441\u044f Twisted. \u0420\u0435\u0448\u0438\u043b \u044f \u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c. \u0418\u0442\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b extmodule.py \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/python import time from twisted.internet import reactor from twisted.internet.protocol import Protocol, ClientFactory  class ExtModuleProtocol(Protocol):          def connectionMade(self):         #%%&gt;connect:&lt;role&gt;         self.transport.write(&quot;%%&gt;connect:global\\n&quot;)  class ExtModuleFactory(ClientFactory):      def buildProtocol(self, addr):         return ExtModuleProtocol()      def clientConnectionLost(self, connector, reason):         print 'Lost connection.  Reason:', reason         time.sleep(2)         connector.connect()      def clientConnectionFailed(self, connector, reason):         print 'Connection failed. Reason:', reason         time.sleep(2)         connector.connect()  def main():     reactor.connectTCP(&quot;localhost&quot;, 5678, ExtModuleFactory())     reactor.run()  if __name__ == '__main__':     main()<\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u044b \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 Yate-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043c Yate, \u0447\u0442\u043e \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0436\u0434\u0435\u0442 \u043e\u0442 \u043d\u0430\u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0422.\u043a. \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0449\u0435 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438: \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u043c\u0435\u043d\u044c\u0448\u0435 32, &quot;%&quot; \u0438 &quot;:&quot;, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0438\u0434.  <\/p>\n<pre><code class=\"python\">def escape(str):     esc_str = ''     for c in str:         if c == &quot;%&quot; or c == &quot;:&quot; or ord(c) &lt; 32:             esc_str += '%' + chr(ord(c) + 64)         else:             esc_str += c     return esc_str  def unescape(str): \tunesc_str = '' \ti = 0 \twhile i &lt; len(str): \t\tc = str[i] \t\tif c == &quot;%&quot;: \t\t\ti += 1 \t\t\tc = chr(ord(str[i]) - 64) \t\ti += 1 \t\tunesc_str += c \treturn unesc_str<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e install_handler \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 connectionMade \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.  <\/p>\n<pre><code class=\"python\">def install_handler(self, message, priority=100, filter_name=None, filter_value=None):     #%%&gt;install:[&lt;priority&gt;]:&lt;name&gt;[:&lt;filter-name&gt;[:&lt;filter-value&gt;]]     install_msg = &quot;%%%%&gt;install:%s:%s&quot; % (priority, escape(message))     if filter_name:         install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_name))         if filter_value:             install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_value))     self.sendMessage(install_msg)<\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">extmodule.py<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">#!\/usr\/bin\/python import time from twisted.internet import reactor from twisted.internet.protocol import Protocol, ClientFactory  def escape(str):     esc_str = ''     for c in str:         if c == &quot;%&quot; or c == &quot;:&quot; or ord(c) &lt; 32:             esc_str += '%' + chr(ord(c) + 64)         else:             esc_str += c     return esc_str  def unescape(str):     unesc_str = ''     i = 0     while i &lt; len(str):         c = str[i]         if c == &quot;%&quot;:             i += 1             c = chr(ord(str[i]) - 64)         i += 1         unesc_str += c     return unesc_str           class ExtModuleProtocol(Protocol):          def sendMessage(self, msg):         print 'sending message %s' % msg         self.transport.write(msg)         self.transport.write(&quot;\\n&quot;)              def connectionMade(self):         #%%&gt;connect:&lt;role&gt;         self.sendMessage(&quot;%%&gt;connect:global&quot;)         self.install_handler('call.route', 100)         self.install_handler('call.execute', 200)             def install_handler(self, message, priority=100, filter_name=None, filter_value=None):         #%%&gt;install:[&lt;priority&gt;]:&lt;name&gt;[:&lt;filter-name&gt;[:&lt;filter-value&gt;]]         install_msg = &quot;%%%%&gt;install:%s:%s&quot; % (priority, escape(message))         if filter_name:             install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_name))             if filter_value:                 install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_value))         self.sendMessage(install_msg)          def dataReceived(self, data):         print data  class ExtModuleFactory(ClientFactory):     def startedConnecting(self, connector):         print 'Started to connect.'      def buildProtocol(self, addr):         print 'Connected.'         return ExtModuleProtocol()      def clientConnectionLost(self, connector, reason):         print 'Lost connection.  Reason:', reason         time.sleep(2)         connector.connect()      def clientConnectionFailed(self, connector, reason):         print 'Connection failed. Reason:', reason         time.sleep(2)         connector.connect()  def main():     reactor.connectTCP(&quot;localhost&quot;, 5678, ExtModuleFactory())     reactor.run()  if __name__ == '__main__':     main()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041d\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e dataReceived. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0431\u044b\u043b\u043e \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u043e, \u0447\u0442\u043e dataReceived \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043a\u043b\u0430\u0441\u0441 ExtModuleProtocol \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 LineReceiver, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 dilemeter \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043c\u0435\u0442\u043e\u0434 lineReceived.  <\/p>\n<pre><code class=\"python\">class ExtModuleProtocol(LineReceiver):          delimiter = '\\n'          def sendMessage(self, msg):         print 'sending message %s' % msg         self.transport.write(msg)         self.transport.write(&quot;\\n&quot;)              def connectionMade(self):         #%%&gt;connect:&lt;role&gt;         self.sendMessage(&quot;%%&gt;connect:global&quot;)         self.install_handler('call.route', 100)         self.install_handler('call.execute', 200)             def install_handler(self, message, priority=100, filter_name=None, filter_value=None):         #%%&gt;install:[&lt;priority&gt;]:&lt;name&gt;[:&lt;filter-name&gt;[:&lt;filter-value&gt;]]         install_msg = &quot;%%%%&gt;install:%s:%s&quot; % (priority, escape(message))         if filter_name:             install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_name))             if filter_value:                 install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_value))         self.sendMessage(install_msg)      def process_request(self, request):         pass          def process_response(self, response):         print &quot;Response received: %s&quot; % response         data = response.split(&quot;:&quot;)         data = [unescape(d) for d in data]         msg_name = data.pop(0)  # getting message name         print 'Message name: %s. Data: %s' % (msg_name, data)         # process received response according the message name          def lineReceived(self, data):         if not data.startswith(&quot;%%&quot;):             print &quot;unknown message received. passing it&quot;         if data[2] == &quot;&gt;&quot;:             self.process_request(data[3:])         else:             self.process_response(data[3:])<\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">extmodule.py<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">#!\/usr\/bin\/python # -*- coding: utf-8 -*- import time from twisted.internet import reactor from twisted.internet.protocol import ClientFactory from twisted.protocols.basic import LineReceiver   def escape(str):     esc_str = ''     for c in str:         if c == &quot;%&quot; or c == &quot;:&quot; or ord(c) &lt; 32:             esc_str += '%' + chr(ord(c) + 64)         else:             esc_str += c     return esc_str  def unescape(str):     unesc_str = ''     i = 0     while i &lt; len(str):         c = str[i]         if c == &quot;%&quot;:             i += 1             c = chr(ord(str[i]) - 64)         i += 1         unesc_str += c     return unesc_str   class ExtModuleProtocol(LineReceiver):          delimiter = '\\n'          def sendMessage(self, msg):         print 'sending message %s' % msg         self.transport.write(msg)         self.transport.write(&quot;\\n&quot;)              def connectionMade(self):         #%%&gt;connect:&lt;role&gt;         self.sendMessage(&quot;%%&gt;connect:global&quot;)         self.install_handler('call.route', 100)         self.install_handler('call.execute', 200)             def install_handler(self, message, priority=100, filter_name=None, filter_value=None):         #%%&gt;install:[&lt;priority&gt;]:&lt;name&gt;[:&lt;filter-name&gt;[:&lt;filter-value&gt;]]         install_msg = &quot;%%%%&gt;install:%s:%s&quot; % (priority, escape(message))         if filter_name:             install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_name))             if filter_value:                 install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_value))         self.sendMessage(install_msg)      def process_request(self, request):         pass          def process_response(self, response):         print &quot;Response received: %s&quot; % response         data = response.split(&quot;:&quot;)         data = [unescape(d) for d in data]         msg_name = data.pop(0)  # getting message key name         print 'Message name: %s. Data: %s' % (msg_name, data)         # process received response according to message name          def lineReceived(self, data):         if not data.startswith(&quot;%%&quot;):             print &quot;unknown message received. passing it&quot;         if data[2] == &quot;&gt;&quot;:             self.process_request(data[3:])         else:             self.process_response(data[3:])  class ExtModuleFactory(ClientFactory):     def startedConnecting(self, connector):         print 'Started to connect.'      def buildProtocol(self, addr):         print 'Connected.'         return ExtModuleProtocol()      def clientConnectionLost(self, connector, reason):         print 'Lost connection.  Reason:', reason         time.sleep(2)         connector.connect()      def clientConnectionFailed(self, connector, reason):         print 'Connection failed. Reason:', reason         time.sleep(2)         connector.connect()  def main():     reactor.connectTCP(&quot;localhost&quot;, 5678, ExtModuleFactory())     reactor.run()  if __name__ == '__main__':     main()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0414\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 enqueue, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e yate.<\/p>\n<pre><code class=\"python\">def enqueue(self, message_name, retvalue, **kwargs):     # %%&gt;message:&lt;id&gt;:&lt;time&gt;:&lt;name&gt;:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]     print &quot;Enqueueing message '%s' with params: %s&quot; % (message_name, kwargs)     params = []     for key, value in kwargs.items()    :         if value:             params.append(escape(&quot;%s=%s&quot; % (key, value)))         else:             params.append(escape(&quot;%s&quot; % key))          msg_id = uuid.uuid4().hex          msg = &quot;%%%%&gt;message:%(id)s:%(time)s:%(name)s:%(retvalue)s:%(params)s&quot; % {         &quot;id&quot;: msg_id,         &quot;time&quot;: int(time.time()),         &quot;name&quot;: escape(message_name),         &quot;retvalue&quot;: escape(retvalue),         &quot;params&quot;: &quot;:&quot;.join(params)     }     self.sendMessage(msg)     return msg_id <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e ID. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 ID. \u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  Enqueueing message &#8216;call.route&#8217; with params: {&#8216;target&#8217;: &#8216;sip:test@127.0.0.1&#8217;}<br \/>  sending message %%&gt;message:<b>3f5e754aaca145b0b257b070e6566cb2<\/b>:1383161706:call.route:None:target=sip%ztest@127.0.0.1<br \/>  \u2026<br \/>  Message name: message. Data: [&#8216;<b>3f5e754aaca145b0b257b070e6566cb2<\/b>&#8216;, &#8216;false&#8217;, &#8216;call.route&#8217;, &#8216;None&#8217;, &#8216;target=sip&#8217;, &#8216;test@127.0.0.1&#8217;, &#8216;handlers=javascript&#8217;, &#8217;15,cdrbuild&#8217;, &#8217;50,fileinfo&#8217;, &#8217;90,subscription&#8217;, &#8216;100,sip&#8217;, &#8216;100,iax&#8217;, &#8216;100,regfile&#8217;, &#8216;100,jingle&#8217;, &#8216;100,regexroute&#8217;, &#8216;100,analog&#8217;, &#8216;100,register&#8217;, &#8216;100,sig&#8217;, &#8216;100&#8217;]<\/p>\n<p>  \u0427\u0442\u043e \u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 process_request.<\/p>\n<pre><code class=\"python\">def process_request(self, request):     print &quot;Request received: %s&quot; % request     data = request.split(&quot;:&quot;)     data = [unescape(d) for d in data]     print &quot;Data: %s&quot; % data     # process received request according the message name<\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">extmodule.py<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">#!\/usr\/bin\/python # -*- coding: utf-8 -*- import time import uuid from twisted.internet import reactor from twisted.internet.protocol import ClientFactory from twisted.protocols.basic import LineReceiver   def escape(str):     esc_str = ''     for c in str:         if c == &quot;%&quot; or c == &quot;:&quot; or ord(c) &lt; 32:             esc_str += '%' + chr(ord(c) + 64)         else:             esc_str += c     return esc_str  def unescape(str):     unesc_str = ''     i = 0     while i &lt; len(str):         c = str[i]         if c == &quot;%&quot;:             i += 1             c = chr(ord(str[i]) - 64)         i += 1         unesc_str += c     return unesc_str           class ExtModuleProtocol(LineReceiver):          delimiter = '\\n'          def sendMessage(self, msg):         print 'sending message %s' % msg         self.transport.write(msg)         self.transport.write(&quot;\\n&quot;)              def enqueue(self, message_name, retvalue, **kwargs):         # %%&gt;message:&lt;id&gt;:&lt;time&gt;:&lt;name&gt;:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]         print &quot;Enqueueing message '%s' with params: %s&quot; % (message_name, kwargs)         params = []         for key, value in kwargs.items()    :             if value:                 params.append(escape(&quot;%s=%s&quot; % (key, value)))             else:                 params.append(escape(&quot;%s&quot; % key))                  msg_id = uuid.uuid4().hex                  msg = &quot;%%%%&gt;message:%(id)s:%(time)s:%(name)s:%(retvalue)s:%(params)s&quot; % {             &quot;id&quot;: msg_id,             &quot;time&quot;: int(time.time()),             &quot;name&quot;: escape(message_name),             &quot;retvalue&quot;: escape(retvalue),             &quot;params&quot;: &quot;:&quot;.join(params)         }         self.sendMessage(msg)         return msg_id              def connectionMade(self):         # %%&gt;connect:&lt;role&gt;         self.sendMessage(&quot;%%&gt;connect:global&quot;)         self.install_handler('call.route', 10)         self.install_handler('call.execute', 200)         self.call_route_msg_id = self.enqueue(&quot;call.route&quot;, &quot;None&quot;, target=&quot;sip:test@127.0.0.1&quot;)             def install_handler(self, message, priority=100, filter_name=None, filter_value=None):         # %%&gt;install:[&lt;priority&gt;]:&lt;name&gt;[:&lt;filter-name&gt;[:&lt;filter-value&gt;]]         install_msg = &quot;%%%%&gt;install:%s:%s&quot; % (priority, escape(message))         if filter_name:             install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_name))             if filter_value:                 install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_value))         self.sendMessage(install_msg)          def process_request(self, request):         print &quot;Request received: %s&quot; % request         data = request.split(&quot;:&quot;)         data = [unescape(d) for d in data]         print &quot;Data: %s&quot; % data         # process received request according the message name          def process_response(self, response):         print &quot;Response received: %s&quot; % response         data = response.split(&quot;:&quot;)         data = [unescape(d) for d in data]         msg_name = data.pop(0)  # getting message key name         print 'Message name: %s. Data: %s' % (msg_name, data)         # process received response according the message name          def lineReceived(self, data):         if not data.startswith(&quot;%%&quot;):             print &quot;unknown message received: %s. passing it&quot; % data         if data[2] == &quot;&gt;&quot;:             self.process_request(data[3:))         else:             self.process_response(data[3:])  class ExtModuleFactory(ClientFactory):     def startedConnecting(self, connector):         print 'Started to connect.'      def buildProtocol(self, addr):         print 'Connected.'         return ExtModuleProtocol()      def clientConnectionLost(self, connector, reason):         print 'Lost connection.  Reason:', reason         time.sleep(2)         connector.connect()      def clientConnectionFailed(self, connector, reason):         print 'Connection failed. Reason:', reason         time.sleep(2)         connector.connect()  def main():     reactor.connectTCP(&quot;localhost&quot;, 5678, ExtModuleFactory())     reactor.run()  if __name__ == '__main__':     main()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440, \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 answer \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434 process_request, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443.  <\/p>\n<pre><code class=\"python\">def answer(self, msg_id, msg_name, processed, retvalue, payload): \t# %%&lt;message:&lt;id&gt;:&lt;processed&gt;:[&lt;name&gt;]:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...] \tprint &quot;Answering the server request&quot; \tparams = [] \tfor key, value in payload.items(): \t\tif value: \t\t\tparams.append(escape(&quot;%s=%s&quot; % (key, value))) \t\telse: \t\t\tparams.append(escape(&quot;%s&quot; % key))  \tmsg = &quot;%%%%&lt;message:%(id)s:%(processed)s:%(name)s:%(retvalue)s:%(params)s&quot; % { \t\t&quot;id&quot;: escape(msg_id), \t\t&quot;processed&quot;: processed and &quot;true&quot; or &quot;false&quot;, \t\t&quot;name&quot;: escape(msg_name), \t\t&quot;retvalue&quot;: escape(retvalue), \t\t&quot;params&quot;: &quot;:&quot;.join(params) \t} \tself.sendMessage(msg)  def process_request(self, request): \tprint &quot;Request received: %s&quot; % request \tdata = request.split(&quot;:&quot;) \tdata = [unescape(d) for d in data] \tprint &quot;Data: %s. Processing message.&quot; % data \tif data[0] == &quot;message&quot;: \t\tmsg_id = data[1] \t\tmsg_name = data[3] \t\tmsg_data = dict(d.split(&quot;=&quot;) for d in data[5:]) \t\tprint &quot;MSG Data: %s&quot; % msg_data \t\tprint &quot;ID: %s. Name: %s&quot; % (msg_id, msg_name) \t\tif msg_name == &quot;call.route&quot; and msg_data.get('called', '') == &quot;123&quot;: \t\t\tself.answer(msg_id, msg_name, True, &quot;sip\/sip:test@127.0.0.1&quot;, {&quot;param1&quot;: &quot;value1&quot;}) \tself.answer(msg_id, msg_name, False, &quot;&quot;, {})<\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">extmodule.py<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">#!\/usr\/bin\/python # -*- coding: utf-8 -*- import time import uuid from twisted.internet import reactor from twisted.internet.protocol import ClientFactory from twisted.protocols.basic import LineReceiver   def escape(str):     esc_str = ''     for c in str:         if c == &quot;%&quot; or c == &quot;:&quot; or ord(c) &lt; 32:             esc_str += '%' + chr(ord(c) + 64)         else:             esc_str += c     return esc_str  def unescape(str):     unesc_str = ''     i = 0     while i &lt; len(str):         c = str[i]         if c == &quot;%&quot;:             i += 1             c = chr(ord(str[i]) - 64)         i += 1         unesc_str += c     return unesc_str   class ExtModuleProtocol(LineReceiver):      delimiter = '\\n'      def sendMessage(self, msg):         print 'sending message %s' % msg         self.transport.write(msg)         self.transport.write(&quot;\\n&quot;)      def enqueue(self, message_name, retvalue, **kwargs):         # %%&gt;message:&lt;id&gt;:&lt;time&gt;:&lt;name&gt;:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]         print &quot;Enqueueing message '%s' with params: %s&quot; % (message_name, kwargs)         params = []         for key, value in kwargs.items():             if value:                 params.append(escape(&quot;%s=%s&quot; % (key, value)))             else:                 params.append(escape(&quot;%s&quot; % key))          msg_id = uuid.uuid4().hex          msg = &quot;%%%%&gt;message:%(id)s:%(time)s:%(name)s:%(retvalue)s:%(params)s&quot; % {             &quot;id&quot;: msg_id,             &quot;time&quot;: int(time.time()),             &quot;name&quot;: escape(message_name),             &quot;retvalue&quot;: escape(retvalue),             &quot;params&quot;: &quot;:&quot;.join(params)         }         self.sendMessage(msg)         return msg_id      def connectionMade(self):         # %%&gt;connect:&lt;role&gt;         self.sendMessage(&quot;%%&gt;connect:global&quot;)         self.install_handler('call.route', 10)         self.install_handler('call.execute', 200)         self.call_route_msg_id = self.enqueue(&quot;call.route&quot;, &quot;None&quot;, target=&quot;sip:test@127.0.0.1&quot;)      def install_handler(self, message, priority=100, filter_name=None, filter_value=None):         # %%&gt;install:[&lt;priority&gt;]:&lt;name&gt;[:&lt;filter-name&gt;[:&lt;filter-value&gt;]]         install_msg = &quot;%%%%&gt;install:%s:%s&quot; % (priority, escape(message))         if filter_name:             install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_name))             if filter_value:                 install_msg = &quot;%s:%s&quot; % (install_msg, escape(filter_value))         self.sendMessage(install_msg)      def answer(self, msg_id, msg_name, processed, retvalue, payload):         # %%&lt;message:&lt;id&gt;:&lt;processed&gt;:[&lt;name&gt;]:&lt;retvalue&gt;[:&lt;key&gt;=&lt;value&gt;...]         print &quot;Answering the server request&quot;         params = []         for key, value in payload.items():             if value:                 params.append(escape(&quot;%s=%s&quot; % (key, value)))             else:                 params.append(escape(&quot;%s&quot; % key))          msg = &quot;%%%%&lt;message:%(id)s:%(processed)s:%(name)s:%(retvalue)s:%(params)s&quot; % {             &quot;id&quot;: escape(msg_id),             &quot;processed&quot;: processed and &quot;true&quot; or &quot;false&quot;,             &quot;name&quot;: escape(msg_name),             &quot;retvalue&quot;: escape(retvalue),             &quot;params&quot;: &quot;:&quot;.join(params)         }         self.sendMessage(msg)      def process_request(self, request):         print &quot;Request received: %s&quot; % request         data = request.split(&quot;:&quot;)         data = [unescape(d) for d in data]         print &quot;Data: %s. Processing message.&quot; % data         if data[0] == &quot;message&quot;:             msg_id = data[1]             msg_name = data[3]             msg_data = dict(d.split(&quot;=&quot;) for d in data[5:])             print &quot;MSG Data: %s&quot; % msg_data             print &quot;ID: %s. Name: %s&quot; % (msg_id, msg_name)             if msg_name == &quot;call.route&quot; and msg_data.get('called', '') == &quot;123&quot;:                 self.answer(msg_id, msg_name, True, &quot;sip\/sip:test@127.0.0.1&quot;, {&quot;param1&quot;: &quot;value1&quot;})         self.answer(msg_id, msg_name, False, &quot;&quot;, {})      def process_response(self, response):         print &quot;Response received: %s&quot; % response         data = response.split(&quot;:&quot;)         data = [unescape(d) for d in data]         msg_name = data.pop(0)  # getting message key name         print 'Message name: %s. Data: %s' % (msg_name, data)         # process received response according the message name      def lineReceived(self, data):         if not data.startswith(&quot;%%&quot;):             print &quot;unknown message received: %s. passing it&quot; % data         if data[2] == &quot;&gt;&quot;:             self.process_request(data[3:])         else:             self.process_response(data[3:])  class ExtModuleFactory(ClientFactory):     def startedConnecting(self, connector):         print 'Started to connect.'      def buildProtocol(self, addr):         print 'Connected.'         return ExtModuleProtocol()      def clientConnectionLost(self, connector, reason):         print 'Lost connection.  Reason:', reason         time.sleep(2)         connector.connect()      def clientConnectionFailed(self, connector, reason):         print 'Connection failed. Reason:', reason         time.sleep(2)         connector.connect()  def main():     reactor.connectTCP(&quot;localhost&quot;, 5678, ExtModuleFactory())     reactor.run()  if __name__ == '__main__':     main()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>\u041c\u0435\u0442\u043e\u0434 answer \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c True, \u0447\u0435\u043c \u0434\u0430\u0441\u0442 \u0437\u043d\u0430\u0442\u044c Yate, \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u043b\u0438 False, \u0442\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u041d\u0430 \u044d\u0442\u043e\u043c \u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0443. \u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<p>  <b>P.S.<\/b> \u041a\u043e\u0434 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u043b\u0438\u0437\u044b\u0432\u0430\u043b\u0441\u044f \u0438 \u043d\u0435 \u0441\u0442\u0440\u0435\u043c\u0438\u043b\u0441\u044f \u043a \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0443. \u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<p>  <b>\u0421\u0441\u044b\u043b\u043a\u0438:<\/b><br \/>  <a href=\"http:\/\/yate.null.ro\/pmwiki\/index.php?n=Main.Extmodule\">yate.null.ro\/pmwiki\/index.php?n=Main.Extmodule<\/a><br \/>  <a href=\"http:\/\/yate.null.ro\/docs\/extmodule.html\">yate.null.ro\/docs\/extmodule.html<\/a>    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\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=\"http:\/\/habrahabr.ru\/post\/199082\/\"> http:\/\/habrahabr.ru\/post\/199082\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0441 \u0412\u0430\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c YATE \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430 python.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/3bb\/725\/efc\/3bb725efc630837682501bb00dc25991.png\"\/> <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0412\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/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-199082","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/199082","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=199082"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/199082\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}