<spanid="welcome-to-socket-protocol-s-documentation"></span><h1>Welcome to socket_protocol’s documentation!<aclass="headerlink"href="#module-socket_protocol"title="Permalink to this headline">¶</a></h1>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">AUTH_STATE_KEY_TRANSFERRED</code><emclass="property"> = 3</em><aclass="headerlink"href="#socket_protocol.AUTH_STATE_KEY_TRANSFERRED"title="Permalink to this definition">¶</a></dt>
<dd><p>Authentification Status for ‘Key has been sent’</p>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">AUTH_STATE_SEED_REQUESTED</code><emclass="property"> = 1</em><aclass="headerlink"href="#socket_protocol.AUTH_STATE_SEED_REQUESTED"title="Permalink to this definition">¶</a></dt>
<dd><p>Authentification Status for ‘Seed was requested’</p>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">AUTH_STATE_SEED_TRANSFERRED</code><emclass="property"> = 2</em><aclass="headerlink"href="#socket_protocol.AUTH_STATE_SEED_TRANSFERRED"title="Permalink to this definition">¶</a></dt>
<dd><p>Authentification Status for ‘Seed has been sent’</p>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">AUTH_STATE_TRUSTED_CONNECTION</code><emclass="property"> = 4</em><aclass="headerlink"href="#socket_protocol.AUTH_STATE_TRUSTED_CONNECTION"title="Permalink to this definition">¶</a></dt>
<dd><p>Authentification Status for a ‘Trusted Connection’</p>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">AUTH_STATE_UNTRUSTED_CONNECTION</code><emclass="property"> = 0</em><aclass="headerlink"href="#socket_protocol.AUTH_STATE_UNTRUSTED_CONNECTION"title="Permalink to this definition">¶</a></dt>
<dd><p>Authentification Status for an ‘Untrusted Connection’</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.AUTH_STATE__NAMES">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">AUTH_STATE__NAMES</code><emclass="property"> = {0: 'Untrusted Connection', 1: 'Seed was requested', 2: 'Seed has been sent', 3: 'Key has been sent', 4: 'Trusted Connection'}</em><aclass="headerlink"href="#socket_protocol.AUTH_STATE__NAMES"title="Permalink to this definition">¶</a></dt>
<dd><p>Authentification Status names for previous defined authentification states</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.DID_AUTH_KEY">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">DID_AUTH_KEY</code><emclass="property"> = 1</em><aclass="headerlink"href="#socket_protocol.DID_AUTH_KEY"title="Permalink to this definition">¶</a></dt>
<dd><p>DID for authentification (key)</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.DID_AUTH_SEED">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">DID_AUTH_SEED</code><emclass="property"> = 0</em><aclass="headerlink"href="#socket_protocol.DID_AUTH_SEED"title="Permalink to this definition">¶</a></dt>
<dd><p>DID for authentification (seed)</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.DID_CHANNEL_NAME">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">DID_CHANNEL_NAME</code><emclass="property"> = 0</em><aclass="headerlink"href="#socket_protocol.DID_CHANNEL_NAME"title="Permalink to this definition">¶</a></dt>
<dd><p>DID for channel name</p>
</dd></dl>
<dlclass="exception">
<dtid="socket_protocol.RequestSidExistsError">
<emclass="property">exception </em><codeclass="descclassname">socket_protocol.</code><codeclass="descname">RequestSidExistsError</code><aclass="headerlink"href="#socket_protocol.RequestSidExistsError"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="exception">
<dtid="socket_protocol.ResponseSidExistsError">
<emclass="property">exception </em><codeclass="descclassname">socket_protocol.</code><codeclass="descname">ResponseSidExistsError</code><aclass="headerlink"href="#socket_protocol.ResponseSidExistsError"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_AUTH_REQUEST">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_AUTH_REQUEST</code><emclass="property"> = 0</em><aclass="headerlink"href="#socket_protocol.SID_AUTH_REQUEST"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for authentification request</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_AUTH_RESPONSE">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_AUTH_RESPONSE</code><emclass="property"> = 1</em><aclass="headerlink"href="#socket_protocol.SID_AUTH_RESPONSE"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for authentification response</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_CHANNEL_NAME_REQUEST">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_CHANNEL_NAME_REQUEST</code><emclass="property"> = 8</em><aclass="headerlink"href="#socket_protocol.SID_CHANNEL_NAME_REQUEST"title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_CHANNEL_NAME_RESPONSE</code><emclass="property"> = 9</em><aclass="headerlink"href="#socket_protocol.SID_CHANNEL_NAME_RESPONSE"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for channel name exchange response</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_EXECUTE_REQUEST">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_EXECUTE_REQUEST</code><emclass="property"> = 30</em><aclass="headerlink"href="#socket_protocol.SID_EXECUTE_REQUEST"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for a execute request</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_EXECUTE_RESPONSE">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_EXECUTE_RESPONSE</code><emclass="property"> = 31</em><aclass="headerlink"href="#socket_protocol.SID_EXECUTE_RESPONSE"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for a execute response</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_READ_REQUEST">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_READ_REQUEST</code><emclass="property"> = 10</em><aclass="headerlink"href="#socket_protocol.SID_READ_REQUEST"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for a read data request</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_READ_RESPONSE">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_READ_RESPONSE</code><emclass="property"> = 11</em><aclass="headerlink"href="#socket_protocol.SID_READ_RESPONSE"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for read data response</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_WRITE_REQUEST">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_WRITE_REQUEST</code><emclass="property"> = 20</em><aclass="headerlink"href="#socket_protocol.SID_WRITE_REQUEST"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for a write data request</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.SID_WRITE_RESPONSE">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">SID_WRITE_RESPONSE</code><emclass="property"> = 21</em><aclass="headerlink"href="#socket_protocol.SID_WRITE_RESPONSE"title="Permalink to this definition">¶</a></dt>
<dd><p>SID for a write data response</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.STATUS_AUTH_REQUIRED">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">STATUS_AUTH_REQUIRED</code><emclass="property"> = 3</em><aclass="headerlink"href="#socket_protocol.STATUS_AUTH_REQUIRED"title="Permalink to this definition">¶</a></dt>
<dd><p>Status for ‘authentification is required’</p>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">STATUS_BUFFERING_UNHANDLED_REQUEST</code><emclass="property"> = 1</em><aclass="headerlink"href="#socket_protocol.STATUS_BUFFERING_UNHANDLED_REQUEST"title="Permalink to this definition">¶</a></dt>
<dd><p>Status for ‘unhandled request’</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.STATUS_CALLBACK_ERROR">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">STATUS_CALLBACK_ERROR</code><emclass="property"> = 2</em><aclass="headerlink"href="#socket_protocol.STATUS_CALLBACK_ERROR"title="Permalink to this definition">¶</a></dt>
<dd><p>Status for ‘callback errors’</p>
</dd></dl>
<dlclass="data">
<dtid="socket_protocol.STATUS_CHECKSUM_ERROR">
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">STATUS_CHECKSUM_ERROR</code><emclass="property"> = 5</em><aclass="headerlink"href="#socket_protocol.STATUS_CHECKSUM_ERROR"title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">STATUS_OKAY</code><emclass="property"> = 0</em><aclass="headerlink"href="#socket_protocol.STATUS_OKAY"title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">STATUS_OPERATION_NOT_PERMITTED</code><emclass="property"> = 6</em><aclass="headerlink"href="#socket_protocol.STATUS_OPERATION_NOT_PERMITTED"title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">socket_protocol.</code><codeclass="descname">STATUS_SERVICE_OR_DATA_UNKNOWN</code><emclass="property"> = 4</em><aclass="headerlink"href="#socket_protocol.STATUS_SERVICE_OR_DATA_UNKNOWN"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="descclassname">socket_protocol.</code><codeclass="descname">data_storage</code><spanclass="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.data_storage"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><ulclass="first last simple">
<li><strong>status</strong> (<em>int</em>) – The message status.</li>
<li><strong>service_id</strong> (<em>int</em>) – The Service-ID.</li>
<li><strong>data_id</strong> (<em>int</em>) – The Data-ID.</li>
<li><strong>data</strong> (<em>any</em>) – The transfered data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dlclass="method">
<dtid="socket_protocol.data_storage.get_data">
<codeclass="descname">get_data</code><spanclass="sig-paren">(</span><em>default=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.data_storage.get_data"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><strong>default</strong>– The default value, if no data is available.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="socket_protocol.data_storage.get_data_id">
<codeclass="descname">get_data_id</code><spanclass="sig-paren">(</span><em>default=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.data_storage.get_data_id"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><strong>default</strong>– The default value, if no data is available.</td>
<codeclass="descname">get_service_id</code><spanclass="sig-paren">(</span><em>default=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.data_storage.get_service_id"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><strong>default</strong>– The default value, if no data is available.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="socket_protocol.data_storage.get_status">
<codeclass="descname">get_status</code><spanclass="sig-paren">(</span><em>default=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.data_storage.get_status"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><strong>default</strong>– The default value, if no data is available.</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="socket_protocol.pure_json_protocol">
<emclass="property">class </em><codeclass="descclassname">socket_protocol.</code><codeclass="descname">pure_json_protocol</code><spanclass="sig-paren">(</span><em>comm_instance</em>, <em>secret=None</em>, <em>auto_auth=False</em>, <em>channel_name=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><ulclass="first last simple">
<li><strong>comm_instance</strong> (<em>instance</em>) – A communication instance.</li>
<li><strong>secret</strong> (<em>str</em>) – An optinal secret (e.g. created by <codeclass="docutils literal notranslate"><spanclass="pre">binascii.hexlify(os.urandom(24))</span></code>).</li>
<li><strong>auto_auth</strong> (<em>bool</em>) – An optional parameter to enable (True) automatic authentification, otherwise you need to do it manually, if needed.</li>
<li>The Service-ID is designed to identify the type of the communication (e.g. <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">READ_REQUEST</span></code>, <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">WRITE_REQUEST</span></code>, <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">READ_RESPONSE</span></code>, <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">WRITE_RESPONSE</span></code>, …)</li>
<li>The Data-ID is designed to identify the requests / responses using the same Service_ID.</li>
</ul>
</div>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<p>The <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">comm_instance</span></code> needs to have at least the following interface:</p>
<li>A Method <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.init_channel_name()</span></code> to set the channel name.</li>
<li>A Constant <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">comm_instance.IS_CLIENT</span></code> to identify that the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">comm_instance</span></code> is a client (True) or a server (False).</li>
<li>A Method <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.is_connected()</span></code> to identify if the instance is connected (True) or not (False).</li>
<li>A Method <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.reconnect()</span></code> to initiate a reconnect.</li>
<li>A Method <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.register_callback()</span></code> to register a data available callback.</li>
<li>A Method <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.register_connect_callback()</span></code> to register a connect callback.</li>
<li>A Method <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.register_disconnect_callback()</span></code> to register a disconnect callback.</li>
<li>A Method <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.send()</span></code> to send data via the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">comm_instance</span></code>.</li>
</ul>
</div>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">The parameter <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">auto_auth</span></code> is only relevant, if a secret is given and the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">comm_instance</span></code> is a client. The authentification is initiated directly after the connection is established.</p>
</div>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<p>The <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">channel_name</span></code>-exchange will be initiated by the client directly after the the connection is established.</p>
<ulclass="last simple">
<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>
<codeclass="descname">add_data</code><spanclass="sig-paren">(</span><em>service_id</em>, <em>data_id</em>, <em>name</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.add_data"title="Permalink to this definition">¶</a></dt>
<dd><p>Method to add a name for a specific message.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><ulclass="first last simple">
<li><strong>service_id</strong> (<em>int</em><em> or </em><em>list of ints</em>) – The Service-ID of the message. See class definitions starting with <codeclass="docutils literal notranslate"><spanclass="pre">SID_</span></code>.</li>
<li><strong>data_id</strong> (<em>int</em>) – The Data-ID of the message.</li>
<li><strong>name</strong> (<em>str</em>) – The Name for the transfered message.</li>
<codeclass="descname">add_msg_to_auth_whitelist_</code><spanclass="sig-paren">(</span><em>service_id</em>, <em>data_id</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.add_msg_to_auth_whitelist_"title="Permalink to this definition">¶</a></dt>
<dd><p>Method to add a specific message to the list, where no authentification is required.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><ulclass="first last simple">
<li><strong>service_id</strong> (<em>int</em>) – The Service-ID of the message. See class definitions starting with <codeclass="docutils literal notranslate"><spanclass="pre">SID_</span></code>.</li>
<li><strong>data_id</strong> (<em>int</em>) – The Data-ID of the message.</li>
<codeclass="descname">add_service</code><spanclass="sig-paren">(</span><em>req_sid</em>, <em>resp_sid</em>, <em>req_name=None</em>, <em>resp_name=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.add_service"title="Permalink to this definition">¶</a></dt>
<dd><p>Method to add a Service defined by Request- and Response Serivce-ID.</p>
<codeclass="descname">add_status</code><spanclass="sig-paren">(</span><em>status</em>, <em>name</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.add_status"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><ulclass="first last simple">
<li><strong>status</strong> (<em>int</em>) – The Status. See class definitions starting with <codeclass="docutils literal notranslate"><spanclass="pre">STATUS_</span></code>.</li>
<li><strong>name</strong> (<em>str</em>) – The Name for the Status.</li>
<codeclass="descname">authentificate</code><spanclass="sig-paren">(</span><em>timeout=2</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.authentificate"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><strong>timeout</strong> (<em>float</em>) – The timeout for the authentification (requesting seed, sending key and getting authentification_feedback).</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body">True, if authentification was successfull; False, if not.</td>
<codeclass="descname">check_authentification_state</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.check_authentification_state"title="Permalink to this definition">¶</a></dt>
<codeclass="descname">connection_established</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.connection_established"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Returns:</th><tdclass="field-body">True, if the connection is established (incl. authentification, if a secret has been given)</td>
<codeclass="descname">is_connected</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.is_connected"title="Permalink to this definition">¶</a></dt>
<dd><p>This Methods returns Connection state of the Communication Instance <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.is_connected()</span></code>.</p>
<trclass="field-odd field"><thclass="field-name">Returns:</th><tdclass="field-body">True if the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">comm_instance</span></code> is connected, otherwise False..</td>
<codeclass="descname">receive</code><spanclass="sig-paren">(</span><em>service_id</em>, <em>data_id</em>, <em>timeout=1</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.receive"title="Permalink to this definition">¶</a></dt>
<li><strong>service_id</strong> (<em>int</em>) – The Service-ID for the message. See class definitions starting with <codeclass="docutils literal notranslate"><spanclass="pre">SID_</span></code>.</li>
<li><strong>data_id</strong> (<em>int</em>) – The Data-ID for the message.</li>
<li><strong>timeout</strong> (<em>float</em>) – The timeout for receiving.</li>
</ul>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first">The received data storage object or None, if no data was received.</p>
<codeclass="descname">reconnect</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.reconnect"title="Permalink to this definition">¶</a></dt>
<dd><p>This methods initiates a reconnect by calling <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">comm_instance.reconnect()</span></code>.</p>
<codeclass="descname">register_callback</code><spanclass="sig-paren">(</span><em>service_id</em>, <em>data_id</em>, <em>callback</em>, <em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.register_callback"title="Permalink to this definition">¶</a></dt>
<dd><p>This method registers a callback for the given parameters. Giving <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code> means, that all Service-IDs or all Data-IDs are used.
If a message hitting these parameters has been received, the callback will be executed.</p>
<li><strong>service_id</strong> (<em>int</em>) – The Service-ID for the message. See class definitions starting with <codeclass="docutils literal notranslate"><spanclass="pre">SID_</span></code>.</li>
<li><strong>data_id</strong> (<em>int</em>) – The Data-ID for the message.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<p>The <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">callback()</span></code> is priorised in the following order:</p>
<ulclass="last simple">
<li>Callbacks with defined Service-ID and Data-ID.</li>
<p><strong>Parameters given at the callback call:</strong></p>
<ulclass="simple">
<li>The first Arguments is the received message as <aclass="reference internal"href="#socket_protocol.data_storage"title="socket_protocol.data_storage"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">data_storage</span></code></a> object.</li>
<li>Further arguments given at registration.</li>
<li>Further keyword arguments given at registration.</li>
</ul>
<p><strong>Return value of the callback:</strong></p>
<p>If the Callback is a Request Callback for a registered Service, the return value has to be a tuple or list with</p>
<li><codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">response_status</span></code>: The response status (see class definitions starting with <codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">STA_*</span></code>.</li>
<li><codeclass="xref py py-const docutils literal notranslate"><spanclass="pre">response_data</span></code>: A JSON iterable object to be used as data for the response.</li>
<codeclass="descname">send</code><spanclass="sig-paren">(</span><em>service_id</em>, <em>data_id</em>, <em>data</em>, <em>status=0</em>, <em>timeout=2</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.pure_json_protocol.send"title="Permalink to this definition">¶</a></dt>
<dd><p>This methods sends out a message with the given content.</p>
<li><strong>service_id</strong> (<em>int</em>) – The Service-ID for the message. See class definitions starting with <codeclass="docutils literal notranslate"><spanclass="pre">SERVICE_</span></code>.</li>
<li><strong>data_id</strong> (<em>int</em>) – The Data-ID for the message.</li>
<li><strong>data</strong> (<em>str</em>) – The data to be transfered. The data needs to be json compatible.</li>
<li><strong>status</strong> (<em>int</em>) – The Status for the message. All requests should have <codeclass="docutils literal notranslate"><spanclass="pre">STATUS_OKAY</span></code>.</li>
<li><strong>timeout</strong> (<em>float</em>) – The timeout for sending data (e.g. time to establish new connection).</li>
</ul>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first">True if data had been sent, otherwise False.</p>
<emclass="property">class </em><codeclass="descclassname">socket_protocol.</code><codeclass="descname">struct_json_protocol</code><spanclass="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#socket_protocol.struct_json_protocol"title="Permalink to this definition">¶</a></dt>
<dd><p>This Class has the same functionality like <aclass="reference internal"href="#socket_protocol.pure_json_protocol"title="socket_protocol.pure_json_protocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">pure_json_protocol</span></code></a>. The message length is less than for <aclass="reference internal"href="#socket_protocol.pure_json_protocol"title="socket_protocol.pure_json_protocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">pure_json_protocol</span></code></a>, but the functionality and compatibility is reduced.
See also parent <aclass="reference internal"href="#socket_protocol.pure_json_protocol"title="socket_protocol.pure_json_protocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">pure_json_protocol</span></code></a>.</p>
<pclass="last">This class is depreceated and here for compatibility reasons (to support old clients or servers). Usage of <aclass="reference internal"href="#socket_protocol.pure_json_protocol"title="socket_protocol.pure_json_protocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">pure_json_protocol</span></code></a> is recommended.</p>
</div>
</dd></dl>
</div>
<divclass="toctree-wrapper compound">
</div>
</div>
<divclass="section"id="indices-and-tables">
<h1>Indices and tables<aclass="headerlink"href="#indices-and-tables"title="Permalink to this headline">¶</a></h1>