Python Library Socket Protocol
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

index.html 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. <!DOCTYPE html>
  2. <html class="writer-html4" lang="en" >
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Welcome to socket_protocol’s documentation! &mdash; socket_protocol documentation</title>
  7. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <!--[if lt IE 9]>
  10. <script src="_static/js/html5shiv.min.js"></script>
  11. <![endif]-->
  12. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  13. <script type="text/javascript" src="_static/jquery.js"></script>
  14. <script type="text/javascript" src="_static/underscore.js"></script>
  15. <script type="text/javascript" src="_static/doctools.js"></script>
  16. <script type="text/javascript" src="_static/language_data.js"></script>
  17. <script type="text/javascript" src="_static/js/theme.js"></script>
  18. <link rel="index" title="Index" href="genindex.html" />
  19. <link rel="search" title="Search" href="search.html" />
  20. </head>
  21. <body class="wy-body-for-nav">
  22. <div class="wy-grid-for-nav">
  23. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  24. <div class="wy-side-scroll">
  25. <div class="wy-side-nav-search" >
  26. <a href="#" class="icon icon-home" alt="Documentation Home"> socket_protocol
  27. </a>
  28. <div role="search">
  29. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  30. <input type="text" name="q" placeholder="Search docs" />
  31. <input type="hidden" name="check_keywords" value="yes" />
  32. <input type="hidden" name="area" value="default" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <!-- Local TOC -->
  38. <div class="local-toc"><ul>
  39. <li><a class="reference internal" href="#">Welcome to socket_protocol’s documentation!</a><ul>
  40. <li><a class="reference internal" href="#socket-protocol-socket-protocol">socket_protocol (Socket Protocol)</a></li>
  41. </ul>
  42. </li>
  43. <li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
  44. </ul>
  45. </div>
  46. </div>
  47. </div>
  48. </nav>
  49. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  50. <nav class="wy-nav-top" aria-label="top navigation">
  51. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  52. <a href="#">socket_protocol</a>
  53. </nav>
  54. <div class="wy-nav-content">
  55. <div class="rst-content">
  56. <div role="navigation" aria-label="breadcrumbs navigation">
  57. <ul class="wy-breadcrumbs">
  58. <li><a href="#" class="icon icon-home"></a> &raquo;</li>
  59. <li>Welcome to socket_protocol’s documentation!</li>
  60. <li class="wy-breadcrumbs-aside">
  61. <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
  62. </li>
  63. </ul>
  64. <hr/>
  65. </div>
  66. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  67. <div itemprop="articleBody">
  68. <div class="section" id="module-socket_protocol">
  69. <span id="welcome-to-socket-protocol-s-documentation"></span><h1>Welcome to socket_protocol’s documentation!<a class="headerlink" href="#module-socket_protocol" title="Permalink to this headline">¶</a></h1>
  70. <div class="section" id="socket-protocol-socket-protocol">
  71. <h2>socket_protocol (Socket Protocol)<a class="headerlink" href="#socket-protocol-socket-protocol" title="Permalink to this headline">¶</a></h2>
  72. <p><strong>Author:</strong></p>
  73. <ul class="simple">
  74. <li>Dirk Alders &lt;<a class="reference external" href="mailto:sudo-dirk&#37;&#52;&#48;mount-mockery&#46;de">sudo-dirk<span>&#64;</span>mount-mockery<span>&#46;</span>de</a>&gt;</li>
  75. </ul>
  76. <p><strong>Description:</strong></p>
  77. <blockquote>
  78. <div>This Module supports point to point communication for client-server issues.</div></blockquote>
  79. <p><strong>Submodules:</strong></p>
  80. <ul class="simple">
  81. <li><a class="reference internal" href="#socket_protocol.pure_json_protocol" title="socket_protocol.pure_json_protocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">socket_protocol.pure_json_protocol</span></code></a></li>
  82. <li><a class="reference internal" href="#socket_protocol.struct_json_protocol" title="socket_protocol.struct_json_protocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">socket_protocol.struct_json_protocol</span></code></a></li>
  83. </ul>
  84. <p><strong>Unittest:</strong></p>
  85. <blockquote>
  86. <div>See also the <a class="reference download internal" download="" href="_downloads/f482679fb1771f4d05403bb87fd0cc34/unittest.pdf"><code class="xref download docutils literal notranslate"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
  87. <p><strong>Module Documentation:</strong></p>
  88. <dl class="class">
  89. <dt id="socket_protocol.data_storage">
  90. <em class="property">class </em><code class="descclassname">socket_protocol.</code><code class="descname">data_storage</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.data_storage" title="Permalink to this definition">¶</a></dt>
  91. <dd><table class="docutils field-list" frame="void" rules="none">
  92. <col class="field-name" />
  93. <col class="field-body" />
  94. <tbody valign="top">
  95. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  96. <li><strong>status</strong> (<em>int</em>) – The message status.</li>
  97. <li><strong>service_id</strong> (<em>int</em>) – The Service-ID.</li>
  98. <li><strong>data_id</strong> (<em>int</em>) – The Data-ID.</li>
  99. <li><strong>data</strong> (<em>any</em>) – The transfered data.</li>
  100. </ul>
  101. </td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. <p>This is a storage object for socket_protocol messages.</p>
  106. <dl class="method">
  107. <dt id="socket_protocol.data_storage.get_data">
  108. <code class="descname">get_data</code><span class="sig-paren">(</span><em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.data_storage.get_data" title="Permalink to this definition">¶</a></dt>
  109. <dd><table class="docutils field-list" frame="void" rules="none">
  110. <col class="field-name" />
  111. <col class="field-body" />
  112. <tbody valign="top">
  113. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>default</strong> – The default value, if no data is available.</td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. <p>This Method returns the message data.</p>
  118. </dd></dl>
  119. <dl class="method">
  120. <dt id="socket_protocol.data_storage.get_data_id">
  121. <code class="descname">get_data_id</code><span class="sig-paren">(</span><em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.data_storage.get_data_id" title="Permalink to this definition">¶</a></dt>
  122. <dd><table class="docutils field-list" frame="void" rules="none">
  123. <col class="field-name" />
  124. <col class="field-body" />
  125. <tbody valign="top">
  126. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>default</strong> – The default value, if no data is available.</td>
  127. </tr>
  128. </tbody>
  129. </table>
  130. <p>This Method returns the message Data-ID.</p>
  131. </dd></dl>
  132. <dl class="method">
  133. <dt id="socket_protocol.data_storage.get_service_id">
  134. <code class="descname">get_service_id</code><span class="sig-paren">(</span><em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.data_storage.get_service_id" title="Permalink to this definition">¶</a></dt>
  135. <dd><table class="docutils field-list" frame="void" rules="none">
  136. <col class="field-name" />
  137. <col class="field-body" />
  138. <tbody valign="top">
  139. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>default</strong> – The default value, if no data is available.</td>
  140. </tr>
  141. </tbody>
  142. </table>
  143. <p>This Method returns the message Service-ID.</p>
  144. </dd></dl>
  145. <dl class="method">
  146. <dt id="socket_protocol.data_storage.get_status">
  147. <code class="descname">get_status</code><span class="sig-paren">(</span><em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.data_storage.get_status" title="Permalink to this definition">¶</a></dt>
  148. <dd><table class="docutils field-list" frame="void" rules="none">
  149. <col class="field-name" />
  150. <col class="field-body" />
  151. <tbody valign="top">
  152. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>default</strong> – The default value, if no data is available.</td>
  153. </tr>
  154. </tbody>
  155. </table>
  156. <p>This Method returns the message status.</p>
  157. </dd></dl>
  158. </dd></dl>
  159. <dl class="class">
  160. <dt id="socket_protocol.pure_json_protocol">
  161. <em class="property">class </em><code class="descclassname">socket_protocol.</code><code class="descname">pure_json_protocol</code><span class="sig-paren">(</span><em>comm_instance</em>, <em>secret=None</em>, <em>auto_auth=False</em>, <em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol" title="Permalink to this definition">¶</a></dt>
  162. <dd><table class="docutils field-list" frame="void" rules="none">
  163. <col class="field-name" />
  164. <col class="field-body" />
  165. <tbody valign="top">
  166. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  167. <li><strong>comm_instance</strong> (<em>instance</em>) – A communication instance.</li>
  168. <li><strong>secret</strong> (<em>str</em>) – An optinal secret (e.g. created by <code class="docutils literal notranslate"><span class="pre">binascii.hexlify(os.urandom(24))</span></code>).</li>
  169. <li><strong>auto_auth</strong> (<em>bool</em>) – An optional parameter (True) to enable automatic authentification, otherwise you need to do it manually, if needed.</li>
  170. <li><strong>channel_name</strong> (<em>str</em>) – An optional parameter to set a channel name for logging of the communication.</li>
  171. </ul>
  172. </td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <div class="admonition hint">
  177. <p class="first admonition-title">Hint</p>
  178. <p>This <cite>class</cite> supports to transfer a Service-ID, Data-ID and Data.</p>
  179. <ul class="last simple">
  180. <li>The Service-ID is designed to identify the type of the communication (e.g. READ_REQUEST, WRITE_REQUEST, READ_RESPONSE, WRITE_RESPONSE, …)</li>
  181. <li>The Data-ID is designed to identify the requests / responses using the same Service_ID.</li>
  182. </ul>
  183. </div>
  184. <div class="admonition note">
  185. <p class="first admonition-title">Note</p>
  186. <p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">comm_instance</span></code> needs to have at least the following interface:</p>
  187. <ul class="last simple">
  188. <li>A Method <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.init_channel_name()</span></code> to set the channel name if needed.</li>
  189. <li>A Constant <code class="xref py py-const docutils literal notranslate"><span class="pre">comm_instance.IS_CLIENT</span></code> to identify that the <code class="xref py py-class docutils literal notranslate"><span class="pre">comm_instance</span></code> is a client (True) or a server (False).</li>
  190. <li>A Method <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.is_connected()</span></code> to identify if the instance is connected (True) or not (False).</li>
  191. <li>A Method <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.reconnect()</span></code> to initiate a reconnect.</li>
  192. <li>A Method <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.register_callback()</span></code> to register a data available callback.</li>
  193. <li>A Method <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.register_connect_callback()</span></code> to register a connect callback.</li>
  194. <li>A Method <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.register_disconnect_callback()</span></code> to register a disconnect callback.</li>
  195. <li>A Method <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.send()</span></code> to send data via the <code class="xref py py-class docutils literal notranslate"><span class="pre">comm_instance</span></code>.</li>
  196. </ul>
  197. </div>
  198. <div class="admonition note">
  199. <p class="first admonition-title">Note</p>
  200. <p class="last">The parameter <code class="xref py py-const docutils literal notranslate"><span class="pre">auto_auth</span></code> is only relevant, if a secret is given and the <code class="xref py py-class docutils literal notranslate"><span class="pre">comm_instance</span></code> is a client. The authentification is initiated directly after the connection is established.</p>
  201. </div>
  202. <div class="admonition note">
  203. <p class="first admonition-title">Note</p>
  204. <p>The <code class="xref py py-const docutils literal notranslate"><span class="pre">channel_name</span></code>-exchange will be initiated by the client directly after the the connection is established.</p>
  205. <ul class="last simple">
  206. <li>If a channel_name is given at both communication sides and they are different, the client name is taken over and the server will log a warning message.</li>
  207. </ul>
  208. </div>
  209. <dl class="attribute">
  210. <dt id="socket_protocol.pure_json_protocol.AUTH_STATE_KEY_TRANSFERRED">
  211. <code class="descname">AUTH_STATE_KEY_TRANSFERRED</code><em class="property"> = 3</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.AUTH_STATE_KEY_TRANSFERRED" title="Permalink to this definition">¶</a></dt>
  212. <dd><p>Authentification Status for ‘Key has been sent’</p>
  213. </dd></dl>
  214. <dl class="attribute">
  215. <dt id="socket_protocol.pure_json_protocol.AUTH_STATE_SEED_REQUESTED">
  216. <code class="descname">AUTH_STATE_SEED_REQUESTED</code><em class="property"> = 1</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.AUTH_STATE_SEED_REQUESTED" title="Permalink to this definition">¶</a></dt>
  217. <dd><p>Authentification Status for ‘Seed was requested’</p>
  218. </dd></dl>
  219. <dl class="attribute">
  220. <dt id="socket_protocol.pure_json_protocol.AUTH_STATE_SEED_TRANSFERRED">
  221. <code class="descname">AUTH_STATE_SEED_TRANSFERRED</code><em class="property"> = 2</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.AUTH_STATE_SEED_TRANSFERRED" title="Permalink to this definition">¶</a></dt>
  222. <dd><p>Authentification Status for ‘Seed has been sent’</p>
  223. </dd></dl>
  224. <dl class="attribute">
  225. <dt id="socket_protocol.pure_json_protocol.AUTH_STATE_TRUSTED_CLIENT">
  226. <code class="descname">AUTH_STATE_TRUSTED_CLIENT</code><em class="property"> = 4</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.AUTH_STATE_TRUSTED_CLIENT" title="Permalink to this definition">¶</a></dt>
  227. <dd><p>Authentification Status for ‘Trusted Connection’</p>
  228. </dd></dl>
  229. <dl class="attribute">
  230. <dt id="socket_protocol.pure_json_protocol.AUTH_STATE_UNKNOWN_CLIENT">
  231. <code class="descname">AUTH_STATE_UNKNOWN_CLIENT</code><em class="property"> = 0</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.AUTH_STATE_UNKNOWN_CLIENT" title="Permalink to this definition">¶</a></dt>
  232. <dd><p>Authentification Status for ‘Unknown Client’</p>
  233. </dd></dl>
  234. <dl class="attribute">
  235. <dt id="socket_protocol.pure_json_protocol.AUTH_STATE__NAMES">
  236. <code class="descname">AUTH_STATE__NAMES</code><em class="property"> = {0: 'Unknown Client', 1: 'Seed was requested', 2: 'Seed has been sent', 3: 'Key has been sent', 4: 'Trusted Connection'}</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.AUTH_STATE__NAMES" title="Permalink to this definition">¶</a></dt>
  237. <dd><p>Authentification Status names for previous defined authentification states</p>
  238. </dd></dl>
  239. <dl class="attribute">
  240. <dt id="socket_protocol.pure_json_protocol.SID_AUTH_KEY_CHECK_REQUEST">
  241. <code class="descname">SID_AUTH_KEY_CHECK_REQUEST</code><em class="property"> = 3</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_AUTH_KEY_CHECK_REQUEST" title="Permalink to this definition">¶</a></dt>
  242. <dd><p>SID for request for checking a key</p>
  243. </dd></dl>
  244. <dl class="attribute">
  245. <dt id="socket_protocol.pure_json_protocol.SID_AUTH_KEY_CHECK_RESPONSE">
  246. <code class="descname">SID_AUTH_KEY_CHECK_RESPONSE</code><em class="property"> = 4</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_AUTH_KEY_CHECK_RESPONSE" title="Permalink to this definition">¶</a></dt>
  247. <dd><p>SID for the authentification response</p>
  248. </dd></dl>
  249. <dl class="attribute">
  250. <dt id="socket_protocol.pure_json_protocol.SID_AUTH_KEY_REQUEST">
  251. <code class="descname">SID_AUTH_KEY_REQUEST</code><em class="property"> = 2</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_AUTH_KEY_REQUEST" title="Permalink to this definition">¶</a></dt>
  252. <dd><p>SID for requesting a key for the given seed</p>
  253. </dd></dl>
  254. <dl class="attribute">
  255. <dt id="socket_protocol.pure_json_protocol.SID_AUTH_SEED_REQUEST">
  256. <code class="descname">SID_AUTH_SEED_REQUEST</code><em class="property"> = 1</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_AUTH_SEED_REQUEST" title="Permalink to this definition">¶</a></dt>
  257. <dd><p>SID for requesting a seed for authentification</p>
  258. </dd></dl>
  259. <dl class="attribute">
  260. <dt id="socket_protocol.pure_json_protocol.SID_CHANNEL_NAME_REQUEST">
  261. <code class="descname">SID_CHANNEL_NAME_REQUEST</code><em class="property"> = 5</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_CHANNEL_NAME_REQUEST" title="Permalink to this definition">¶</a></dt>
  262. <dd><p>SID for requesting a channel name exchange</p>
  263. </dd></dl>
  264. <dl class="attribute">
  265. <dt id="socket_protocol.pure_json_protocol.SID_CHANNEL_NAME_RESPONSE">
  266. <code class="descname">SID_CHANNEL_NAME_RESPONSE</code><em class="property"> = 6</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_CHANNEL_NAME_RESPONSE" title="Permalink to this definition">¶</a></dt>
  267. <dd><p>SID for the channel name response</p>
  268. </dd></dl>
  269. <dl class="attribute">
  270. <dt id="socket_protocol.pure_json_protocol.SID_EXECUTE_REQUEST">
  271. <code class="descname">SID_EXECUTE_REQUEST</code><em class="property"> = 30</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_EXECUTE_REQUEST" title="Permalink to this definition">¶</a></dt>
  272. <dd><p>SID for a execute request</p>
  273. </dd></dl>
  274. <dl class="attribute">
  275. <dt id="socket_protocol.pure_json_protocol.SID_EXECUTE_RESPONSE">
  276. <code class="descname">SID_EXECUTE_RESPONSE</code><em class="property"> = 31</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_EXECUTE_RESPONSE" title="Permalink to this definition">¶</a></dt>
  277. <dd><p>SID for a execute response</p>
  278. </dd></dl>
  279. <dl class="attribute">
  280. <dt id="socket_protocol.pure_json_protocol.SID_READ_REQUEST">
  281. <code class="descname">SID_READ_REQUEST</code><em class="property"> = 10</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_READ_REQUEST" title="Permalink to this definition">¶</a></dt>
  282. <dd><p>SID for a read data request</p>
  283. </dd></dl>
  284. <dl class="attribute">
  285. <dt id="socket_protocol.pure_json_protocol.SID_READ_RESPONSE">
  286. <code class="descname">SID_READ_RESPONSE</code><em class="property"> = 11</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_READ_RESPONSE" title="Permalink to this definition">¶</a></dt>
  287. <dd><p>SID for read data response</p>
  288. </dd></dl>
  289. <dl class="attribute">
  290. <dt id="socket_protocol.pure_json_protocol.SID_WRITE_REQUEST">
  291. <code class="descname">SID_WRITE_REQUEST</code><em class="property"> = 20</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_WRITE_REQUEST" title="Permalink to this definition">¶</a></dt>
  292. <dd><p>SID for a write data request</p>
  293. </dd></dl>
  294. <dl class="attribute">
  295. <dt id="socket_protocol.pure_json_protocol.SID_WRITE_RESPONSE">
  296. <code class="descname">SID_WRITE_RESPONSE</code><em class="property"> = 21</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID_WRITE_RESPONSE" title="Permalink to this definition">¶</a></dt>
  297. <dd><p>SID for a write data response</p>
  298. </dd></dl>
  299. <dl class="attribute">
  300. <dt id="socket_protocol.pure_json_protocol.SID__NO_AUTH_LIST">
  301. <code class="descname">SID__NO_AUTH_LIST</code><em class="property"> = [1, 2, 3, 4, 5, 6]</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID__NO_AUTH_LIST" title="Permalink to this definition">¶</a></dt>
  302. <dd><p>List of SIDs without need of an authentification</p>
  303. </dd></dl>
  304. <dl class="attribute">
  305. <dt id="socket_protocol.pure_json_protocol.SID__RESPONSE_DICT">
  306. <code class="descname">SID__RESPONSE_DICT</code><em class="property"> = {1: 2, 2: 3, 3: 4, 5: 6, 10: 11, 20: 21, 30: 31}</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.SID__RESPONSE_DICT" title="Permalink to this definition">¶</a></dt>
  307. <dd><p>Dictionary to get the SID for the response by the key which is the SID for the request</p>
  308. </dd></dl>
  309. <dl class="attribute">
  310. <dt id="socket_protocol.pure_json_protocol.STATUS_AUTH_REQUIRED">
  311. <code class="descname">STATUS_AUTH_REQUIRED</code><em class="property"> = 2</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.STATUS_AUTH_REQUIRED" title="Permalink to this definition">¶</a></dt>
  312. <dd><p>Status for ‘authentification is required’</p>
  313. </dd></dl>
  314. <dl class="attribute">
  315. <dt id="socket_protocol.pure_json_protocol.STATUS_BUFFERING_UNHANDLED_REQUEST">
  316. <code class="descname">STATUS_BUFFERING_UNHANDLED_REQUEST</code><em class="property"> = 1</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.STATUS_BUFFERING_UNHANDLED_REQUEST" title="Permalink to this definition">¶</a></dt>
  317. <dd><p>Status for ‘unhandled request’</p>
  318. </dd></dl>
  319. <dl class="attribute">
  320. <dt id="socket_protocol.pure_json_protocol.STATUS_CHECKSUM_ERROR">
  321. <code class="descname">STATUS_CHECKSUM_ERROR</code><em class="property"> = 4</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.STATUS_CHECKSUM_ERROR" title="Permalink to this definition">¶</a></dt>
  322. <dd><p>Status for ‘checksum error’</p>
  323. </dd></dl>
  324. <dl class="attribute">
  325. <dt id="socket_protocol.pure_json_protocol.STATUS_OKAY">
  326. <code class="descname">STATUS_OKAY</code><em class="property"> = 0</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.STATUS_OKAY" title="Permalink to this definition">¶</a></dt>
  327. <dd><p>Status for ‘okay’</p>
  328. </dd></dl>
  329. <dl class="attribute">
  330. <dt id="socket_protocol.pure_json_protocol.STATUS_OPERATION_NOT_PERMITTED">
  331. <code class="descname">STATUS_OPERATION_NOT_PERMITTED</code><em class="property"> = 5</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.STATUS_OPERATION_NOT_PERMITTED" title="Permalink to this definition">¶</a></dt>
  332. <dd><p>Status for ‘operation not permitted’</p>
  333. </dd></dl>
  334. <dl class="attribute">
  335. <dt id="socket_protocol.pure_json_protocol.STATUS_SERVICE_OR_DATA_UNKNOWN">
  336. <code class="descname">STATUS_SERVICE_OR_DATA_UNKNOWN</code><em class="property"> = 3</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.STATUS_SERVICE_OR_DATA_UNKNOWN" title="Permalink to this definition">¶</a></dt>
  337. <dd><p>Status for ‘service or data unknown’</p>
  338. </dd></dl>
  339. <dl class="attribute">
  340. <dt id="socket_protocol.pure_json_protocol.STATUS__NAMES">
  341. <code class="descname">STATUS__NAMES</code><em class="property"> = {0: 'Okay', 1: 'Request has no callback. Data buffered.', 2: 'Authentification required', 3: 'Service or Data unknown', 4: 'Checksum Error', 5: 'Operation not permitted'}</em><a class="headerlink" href="#socket_protocol.pure_json_protocol.STATUS__NAMES" title="Permalink to this definition">¶</a></dt>
  342. <dd><p>Status names for previous defined states</p>
  343. </dd></dl>
  344. <dl class="method">
  345. <dt id="socket_protocol.pure_json_protocol.authentificate">
  346. <code class="descname">authentificate</code><span class="sig-paren">(</span><em>timeout=2</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.authentificate" title="Permalink to this definition">¶</a></dt>
  347. <dd><table class="docutils field-list" frame="void" rules="none">
  348. <col class="field-name" />
  349. <col class="field-body" />
  350. <tbody valign="top">
  351. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>timeout</strong> (<em>float</em>) – The timeout for the authentification (requesting seed, sending key and getting authentification_feedback).</td>
  352. </tr>
  353. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True, if authentification was successfull; False, if not.</td>
  354. </tr>
  355. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  356. </tr>
  357. </tbody>
  358. </table>
  359. <p>This method authetificates the client at the server.</p>
  360. <div class="admonition note">
  361. <p class="first admonition-title">Note</p>
  362. <p class="last">An authentification will only processed, if a secret had been given on initialisation.</p>
  363. </div>
  364. <div class="admonition note">
  365. <p class="first admonition-title">Note</p>
  366. <p class="last">Client and Server needs to use the same secret.</p>
  367. </div>
  368. </dd></dl>
  369. <dl class="method">
  370. <dt id="socket_protocol.pure_json_protocol.check_authentification_state">
  371. <code class="descname">check_authentification_state</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.check_authentification_state" title="Permalink to this definition">¶</a></dt>
  372. <dd><table class="docutils field-list" frame="void" rules="none">
  373. <col class="field-name" />
  374. <col class="field-body" />
  375. <tbody valign="top">
  376. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True, if authentification state is okay, otherwise False</td>
  377. </tr>
  378. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  379. </tr>
  380. </tbody>
  381. </table>
  382. </dd></dl>
  383. <dl class="method">
  384. <dt id="socket_protocol.pure_json_protocol.connection_established">
  385. <code class="descname">connection_established</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.connection_established" title="Permalink to this definition">¶</a></dt>
  386. <dd><table class="docutils field-list" frame="void" rules="none">
  387. <col class="field-name" />
  388. <col class="field-body" />
  389. <tbody valign="top">
  390. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True, if the connection is established (incl. authentification, if a secret has been given)</td>
  391. </tr>
  392. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  393. </tr>
  394. </tbody>
  395. </table>
  396. </dd></dl>
  397. <dl class="method">
  398. <dt id="socket_protocol.pure_json_protocol.is_connected">
  399. <code class="descname">is_connected</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.is_connected" title="Permalink to this definition">¶</a></dt>
  400. <dd><table class="docutils field-list" frame="void" rules="none">
  401. <col class="field-name" />
  402. <col class="field-body" />
  403. <tbody valign="top">
  404. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if the <code class="xref py py-class docutils literal notranslate"><span class="pre">comm_instance</span></code> is connected, otherwise False..</td>
  405. </tr>
  406. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  407. </tr>
  408. </tbody>
  409. </table>
  410. <p>This methods returns the return value of <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.is_connected()</span></code>.</p>
  411. </dd></dl>
  412. <dl class="method">
  413. <dt id="socket_protocol.pure_json_protocol.receive">
  414. <code class="descname">receive</code><span class="sig-paren">(</span><em>service_id</em>, <em>data_id</em>, <em>timeout=1</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.receive" title="Permalink to this definition">¶</a></dt>
  415. <dd><table class="docutils field-list" frame="void" rules="none">
  416. <col class="field-name" />
  417. <col class="field-body" />
  418. <tbody valign="top">
  419. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  420. <li><strong>service_id</strong> (<em>int</em>) – The Service-ID for the message. See class definitions starting with <code class="docutils literal notranslate"><span class="pre">SID_</span></code>.</li>
  421. <li><strong>data_id</strong> (<em>int</em>) – The Data-ID for the message.</li>
  422. <li><strong>timeout</strong> (<em>float</em>) – The timeout for receiving.</li>
  423. </ul>
  424. </td>
  425. </tr>
  426. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The received data storage object or None, if no data was received.</p>
  427. </td>
  428. </tr>
  429. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference internal" href="#socket_protocol.data_storage" title="socket_protocol.data_storage">data_storage</a></p>
  430. </td>
  431. </tr>
  432. </tbody>
  433. </table>
  434. </dd></dl>
  435. <dl class="method">
  436. <dt id="socket_protocol.pure_json_protocol.reconnect">
  437. <code class="descname">reconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.reconnect" title="Permalink to this definition">¶</a></dt>
  438. <dd><p>This methods initiates a reconnect by calling <code class="xref py py-func docutils literal notranslate"><span class="pre">comm_instance.reconnect()</span></code>.</p>
  439. </dd></dl>
  440. <dl class="method">
  441. <dt id="socket_protocol.pure_json_protocol.register_callback">
  442. <code class="descname">register_callback</code><span class="sig-paren">(</span><em>service_id</em>, <em>data_id</em>, <em>callback</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.register_callback" title="Permalink to this definition">¶</a></dt>
  443. <dd><table class="docutils field-list" frame="void" rules="none">
  444. <col class="field-name" />
  445. <col class="field-body" />
  446. <tbody valign="top">
  447. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  448. <li><strong>service_id</strong> (<em>int</em>) – The Service-ID for the message. See class definitions starting with <code class="docutils literal notranslate"><span class="pre">SID_</span></code>.</li>
  449. <li><strong>data_id</strong> (<em>int</em>) – The Data-ID for the message.</li>
  450. </ul>
  451. </td>
  452. </tr>
  453. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True, if registration was successfull; False, if registration failed (e.g. existance of a callback for this configuration)</p>
  454. </td>
  455. </tr>
  456. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  457. </td>
  458. </tr>
  459. </tbody>
  460. </table>
  461. <p>This method registers a callback for the given parameters. Givin <code class="docutils literal notranslate"><span class="pre">None</span></code> means, that all Service-IDs or all Data-IDs are used.
  462. If a message hitting these parameters has been received, the callback will be executed.</p>
  463. <div class="admonition note">
  464. <p class="first admonition-title">Note</p>
  465. <p>The <code class="xref py py-func docutils literal notranslate"><span class="pre">callback()</span></code> is priorised in the following order:</p>
  466. <ul class="last simple">
  467. <li>Callbacks with defined Service-ID and Data-ID.</li>
  468. <li>Callbacks with a defined Data-ID.</li>
  469. <li>Callbacks with a defined Service-ID.</li>
  470. <li>Unspecific Callbacks</li>
  471. </ul>
  472. </div>
  473. <div class="admonition note">
  474. <p class="first admonition-title">Note</p>
  475. <p>The <code class="xref py py-func docutils literal notranslate"><span class="pre">callback()</span></code> is executed with these arguments:</p>
  476. <table class="docutils field-list" frame="void" rules="none">
  477. <col class="field-name" />
  478. <col class="field-body" />
  479. <tbody valign="top">
  480. <tr class="field-odd field"><th class="field-name">param msg:</th><td class="field-body">A <a class="reference internal" href="#socket_protocol.data_storage" title="socket_protocol.data_storage"><code class="xref py py-class docutils literal notranslate"><span class="pre">data_storage</span></code></a> object containing all message information.</td>
  481. </tr>
  482. <tr class="field-even field"><th class="field-name">returns:</th><td class="field-body">(<code class="xref py py-const docutils literal notranslate"><span class="pre">status</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">response_data</span></code>)</td>
  483. </tr>
  484. </tbody>
  485. </table>
  486. <ul class="last simple">
  487. <li><code class="xref py py-const docutils literal notranslate"><span class="pre">status</span></code>: A status as defined as a constant of this class <code class="xref py py-const docutils literal notranslate"><span class="pre">STA_*</span></code> to be used as status for the response.</li>
  488. <li><code class="xref py py-const docutils literal notranslate"><span class="pre">response_data</span></code>: A JSON iterable object to be used as data for the response.</li>
  489. </ul>
  490. </div>
  491. <div class="admonition note">
  492. <p class="first admonition-title">Note</p>
  493. <p class="last">Only callbacks defined in <a class="reference internal" href="#socket_protocol.pure_json_protocol.SID__RESPONSE_DICT" title="socket_protocol.pure_json_protocol.SID__RESPONSE_DICT"><code class="xref py py-const docutils literal notranslate"><span class="pre">pure_json_protocol.SID__RESPONSE_DICT</span></code></a> will send a response, using a Service-ID given in the dict and the same Data-ID to the client.</p>
  494. </div>
  495. </dd></dl>
  496. <dl class="method">
  497. <dt id="socket_protocol.pure_json_protocol.send">
  498. <code class="descname">send</code><span class="sig-paren">(</span><em>service_id</em>, <em>data_id</em>, <em>data</em>, <em>status=0</em>, <em>timeout=2</em>, <em>log_lvl=20</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.pure_json_protocol.send" title="Permalink to this definition">¶</a></dt>
  499. <dd><table class="docutils field-list" frame="void" rules="none">
  500. <col class="field-name" />
  501. <col class="field-body" />
  502. <tbody valign="top">
  503. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  504. <li><strong>service_id</strong> (<em>int</em>) – The Service-ID for the message. See class definitions starting with <code class="docutils literal notranslate"><span class="pre">SERVICE_</span></code>.</li>
  505. <li><strong>data_id</strong> (<em>int</em>) – The Data-ID for the message.</li>
  506. <li><strong>data</strong> (<em>str</em>) – The data to be transfered. The data needs to be json compatible.</li>
  507. <li><strong>status</strong> (<em>int</em>) – The Status for the message. All requests should have <code class="docutils literal notranslate"><span class="pre">STATUS_OKAY</span></code>.</li>
  508. <li><strong>timeout</strong> (<em>float</em>) – The timeout for sending data (e.g. time to establish new connection).</li>
  509. <li><strong>rx_log_lvl</strong> (<em>int</em>) – The log level to log outgoing TX-data</li>
  510. </ul>
  511. </td>
  512. </tr>
  513. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if data had been sent, otherwise False.</p>
  514. </td>
  515. </tr>
  516. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  517. </td>
  518. </tr>
  519. </tbody>
  520. </table>
  521. <p>This methods sends out a message with the given content.</p>
  522. </dd></dl>
  523. </dd></dl>
  524. <dl class="class">
  525. <dt id="socket_protocol.struct_json_protocol">
  526. <em class="property">class </em><code class="descclassname">socket_protocol.</code><code class="descname">struct_json_protocol</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#socket_protocol.struct_json_protocol" title="Permalink to this definition">¶</a></dt>
  527. <dd><p>This Class has the same functionality like <a class="reference internal" href="#socket_protocol.pure_json_protocol" title="socket_protocol.pure_json_protocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">pure_json_protocol</span></code></a>. The message length is less than for <a class="reference internal" href="#socket_protocol.pure_json_protocol" title="socket_protocol.pure_json_protocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">pure_json_protocol</span></code></a>, but the functionality and compatibility is reduced.</p>
  528. <div class="admonition note">
  529. <p class="first admonition-title">Note</p>
  530. <p class="last">This class is depreceated and here for compatibility reasons (to support old clients or servers). Usage of <a class="reference internal" href="#socket_protocol.pure_json_protocol" title="socket_protocol.pure_json_protocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">pure_json_protocol</span></code></a> is recommended.</p>
  531. </div>
  532. </dd></dl>
  533. </div>
  534. <div class="toctree-wrapper compound">
  535. </div>
  536. </div>
  537. <div class="section" id="indices-and-tables">
  538. <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
  539. <ul class="simple">
  540. <li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
  541. <li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
  542. <li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
  543. </ul>
  544. </div>
  545. </div>
  546. </div>
  547. <footer>
  548. <hr/>
  549. <div role="contentinfo">
  550. <p>
  551. &copy; Copyright 2021, Dirk Alders
  552. </p>
  553. </div>
  554. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
  555. <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
  556. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  557. </footer>
  558. </div>
  559. </div>
  560. </section>
  561. </div>
  562. <script type="text/javascript">
  563. jQuery(function () {
  564. SphinxRtdTheme.Navigation.enable(true);
  565. });
  566. </script>
  567. </body>
  568. </html>