1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/docs/html/network.html
2019-04-24 19:57:15 +02:00

442 lines
No EOL
24 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>royalnet.network &mdash; Royalnet documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="royalnet.utils" href="utils.html" />
<link rel="prev" title="royalnet.database" href="database.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Royalnet
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="audio.html">royalnet.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="bots.html">royalnet.bots</a></li>
<li class="toctree-l1"><a class="reference internal" href="commands.html">royalnet.commands</a></li>
<li class="toctree-l1"><a class="reference internal" href="database.html">royalnet.database</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">royalnet.network</a><ul class="simple">
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="utils.html">royalnet.utils</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Royalnet</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li>royalnet.network</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/network.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="royalnet-network">
<h1>royalnet.network<a class="headerlink" href="#royalnet-network" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound">
</div>
<span class="target" id="module-royalnet.network"></span><dl class="class">
<dt id="royalnet.network.Message">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">Message</code><a class="headerlink" href="#royalnet.network.Message" title="Permalink to this definition"></a></dt>
<dd><p>A message sent through the Royalnet.</p>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.ServerErrorMessage">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">ServerErrorMessage</code><span class="sig-paren">(</span><em>reason</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.ServerErrorMessage" title="Permalink to this definition"></a></dt>
<dd><p>Something went wrong in the connection to the <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.InvalidSecretEM">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">InvalidSecretEM</code><span class="sig-paren">(</span><em>reason</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.InvalidSecretEM" title="Permalink to this definition"></a></dt>
<dd><p>The sent secret was incorrect.</p>
<p>This message terminates connection to the <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.InvalidDestinationEM">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">InvalidDestinationEM</code><span class="sig-paren">(</span><em>reason</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.InvalidDestinationEM" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#royalnet.network.Package" title="royalnet.network.Package"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Package</span></code></a> destination was invalid or not found.</p>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.InvalidPackageEM">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">InvalidPackageEM</code><span class="sig-paren">(</span><em>reason</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.InvalidPackageEM" title="Permalink to this definition"></a></dt>
<dd><p>The sent <a class="reference internal" href="#royalnet.network.Package" title="royalnet.network.Package"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Package</span></code></a> was invalid.</p>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.RoyalnetLink">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetLink</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>secret: str</em>, <em>link_type: str</em>, <em>request_handler</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink" title="Permalink to this definition"></a></dt>
<dd><dl class="method">
<dt id="royalnet.network.RoyalnetLink.connect">
<code class="descname">connect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink.connect" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetLink.identify">
<code class="descname">identify</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#royalnet.network.RoyalnetLink.identify" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetLink.receive">
<code class="descname">receive</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; royalnet.network.packages.Package<a class="headerlink" href="#royalnet.network.RoyalnetLink.receive" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetLink.request">
<code class="descname">request</code><span class="sig-paren">(</span><em>message</em>, <em>destination</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink.request" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetLink.run">
<code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink.run" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetLink.send">
<code class="descname">send</code><span class="sig-paren">(</span><em>package: royalnet.network.packages.Package</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetLink.send" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="exception">
<dt id="royalnet.network.NetworkError">
<em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NetworkError</code><span class="sig-paren">(</span><em>error_msg: royalnet.network.messages.ServerErrorMessage</em>, <em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.NetworkError" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="exception">
<dt id="royalnet.network.NotConnectedError">
<em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NotConnectedError</code><a class="headerlink" href="#royalnet.network.NotConnectedError" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#royalnet.network.RoyalnetLink" title="royalnet.network.RoyalnetLink"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetLink</span></code></a> is not connected to a <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p>
</dd></dl>
<dl class="exception">
<dt id="royalnet.network.NotIdentifiedError">
<em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NotIdentifiedError</code><a class="headerlink" href="#royalnet.network.NotIdentifiedError" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="#royalnet.network.RoyalnetLink" title="royalnet.network.RoyalnetLink"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetLink</span></code></a> has not identified yet to a <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.Package">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">Package</code><span class="sig-paren">(</span><em>data</em>, <em>destination: str</em>, <em>source: str</em>, <em>*</em>, <em>source_conv_id: str = None</em>, <em>destination_conv_id: str = None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.Package" title="Permalink to this definition"></a></dt>
<dd><p>A Royalnet package, the data type with which a <a class="reference internal" href="#royalnet.network.RoyalnetLink" title="royalnet.network.RoyalnetLink"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetLink</span></code></a> communicates with a <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a> or another link.</p>
<dl class="method">
<dt id="royalnet.network.Package.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>data</em>, <em>destination: str</em>, <em>source: str</em>, <em>*</em>, <em>source_conv_id: str = None</em>, <em>destination_conv_id: str = None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.Package.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Create a Package.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> The data that should be sent. Usually a <a class="reference internal" href="#royalnet.network.Message" title="royalnet.network.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Message</span></code></a>.</p></li>
<li><p><strong>destination</strong> The <code class="docutils literal notranslate"><span class="pre">link_type</span></code> of the destination node, or alternatively, the <code class="docutils literal notranslate"><span class="pre">nid</span></code> of the node. Can also be the <code class="docutils literal notranslate"><span class="pre">NULL</span></code> value to send the message to nobody.</p></li>
<li><p><strong>source</strong> The <code class="docutils literal notranslate"><span class="pre">nid</span></code> of the node that created this Package.</p></li>
<li><p><strong>source_conv_id</strong> The conversation id of the node that created this package. Akin to the sequence number on IP packets.</p></li>
<li><p><strong>destination_conv_id</strong> The conversation id of the node that this Package is a reply to.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="royalnet.network.Package.pickle">
<code class="descname">pickle</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; bytes<a class="headerlink" href="#royalnet.network.Package.pickle" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://docs.python.org/3.7/library/pickle.html#module-pickle" title="(in Python v3.7)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a> this Package.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The pickled package in form of bytes.</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="royalnet.network.Package.reply">
<code class="descname">reply</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span> &#x2192; royalnet.network.packages.Package<a class="headerlink" href="#royalnet.network.Package.reply" title="Permalink to this definition"></a></dt>
<dd><p>Reply to this Package with another Package.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>data</strong> The data that should be sent. Usually a <a class="reference internal" href="#royalnet.network.Message" title="royalnet.network.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Message</span></code></a>.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The reply Package.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.RoyalnetServer">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetServer</code><span class="sig-paren">(</span><em>address: str</em>, <em>port: int</em>, <em>required_secret: str</em>, <em>*</em>, <em>loop: asyncio.events.AbstractEventLoop = &lt;_WindowsSelectorEventLoop running=False closed=False debug=False&gt;</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetServer" title="Permalink to this definition"></a></dt>
<dd><dl class="method">
<dt id="royalnet.network.RoyalnetServer.find_client">
<code class="descname">find_client</code><span class="sig-paren">(</span><em>*</em>, <em>nid: str = None</em>, <em>link_type: str = None</em><span class="sig-paren">)</span> &#x2192; List[royalnet.network.royalnetserver.ConnectedClient]<a class="headerlink" href="#royalnet.network.RoyalnetServer.find_client" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetServer.find_destination">
<code class="descname">find_destination</code><span class="sig-paren">(</span><em>package: royalnet.network.packages.Package</em><span class="sig-paren">)</span> &#x2192; List[royalnet.network.royalnetserver.ConnectedClient]<a class="headerlink" href="#royalnet.network.RoyalnetServer.find_destination" title="Permalink to this definition"></a></dt>
<dd><p>Find a list of destinations for the package.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>package</strong> The package to find the destination of.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#list" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> of <code class="xref py py-class docutils literal notranslate"><span class="pre">ConnectedClients</span></code> to send the package to.</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetServer.listener">
<code class="descname">listener</code><span class="sig-paren">(</span><em>websocket: websockets.server.WebSocketServerProtocol</em>, <em>request_uri: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetServer.listener" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetServer.route_package">
<code class="descname">route_package</code><span class="sig-paren">(</span><em>package: royalnet.network.packages.Package</em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#royalnet.network.RoyalnetServer.route_package" title="Permalink to this definition"></a></dt>
<dd><p>Executed every time a package is received and must be routed somewhere.</p>
</dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetServer.serve">
<code class="descname">serve</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetServer.serve" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="royalnet.network.RoyalnetServer.start">
<code class="descname">start</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetServer.start" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.RequestSuccessful">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RequestSuccessful</code><a class="headerlink" href="#royalnet.network.RequestSuccessful" title="Permalink to this definition"></a></dt>
<dd><p>The sent request was successful.</p>
<dl class="method">
<dt id="royalnet.network.RequestSuccessful.raise_on_error">
<code class="descname">raise_on_error</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#royalnet.network.RequestSuccessful.raise_on_error" title="Permalink to this definition"></a></dt>
<dd><p>If the reply is an error, raise an error, otherwise, do nothing.</p>
<p>Does nothing.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.RequestError">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RequestError</code><span class="sig-paren">(</span><em>exc: Exception</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RequestError" title="Permalink to this definition"></a></dt>
<dd><p>The sent request wasnt successful.</p>
<dl class="method">
<dt id="royalnet.network.RequestError.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>exc: Exception</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RequestError.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Create a RequestError.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>exc</strong> The exception that caused the error in the request.</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="royalnet.network.RequestError.raise_on_error">
<code class="descname">raise_on_error</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#royalnet.network.RequestError.raise_on_error" title="Permalink to this definition"></a></dt>
<dd><p>If the reply is an error, raise an error, otherwise, do nothing.</p>
<p>:raises Always raises a <code class="xref py py-exc docutils literal notranslate"><span class="pre">royalnet.error.RoyalnetError</span></code>, containing the exception that caused the error.:</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="royalnet.network.RoyalnetConfig">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">RoyalnetConfig</code><span class="sig-paren">(</span><em>master_uri: str</em>, <em>master_secret: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.network.RoyalnetConfig" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="royalnet.network.Reply">
<em class="property">class </em><code class="descclassname">royalnet.network.</code><code class="descname">Reply</code><a class="headerlink" href="#royalnet.network.Reply" title="Permalink to this definition"></a></dt>
<dd><p>A reply to a request sent through the Royalnet.</p>
<dl class="method">
<dt id="royalnet.network.Reply.raise_on_error">
<code class="descname">raise_on_error</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#royalnet.network.Reply.raise_on_error" title="Permalink to this definition"></a></dt>
<dd><p>If the reply is an error, raise an error, otherwise, do nothing.</p>
<p>:raises A <code class="xref py py-exc docutils literal notranslate"><span class="pre">RoyalnetError</span></code>, if the Reply is an error, otherwise, nothing.:</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="utils.html" class="btn btn-neutral float-right" title="royalnet.utils" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="database.html" class="btn btn-neutral float-left" title="royalnet.database" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2019, Stefano Pigozzi
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>