
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/client/1_connection.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_client_1_connection.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_client_1_connection.py:


Client
======

Showcases the life-cycle of an Aseba client.

.. GENERATED FROM PYTHON SOURCE LINES 9-11

1. Create the client
--------------------

.. GENERATED FROM PYTHON SOURCE LINES 11-16

.. code-block:: Python


    from pyaseba.client import Client

    client = Client()








.. GENERATED FROM PYTHON SOURCE LINES 17-19

2. Connect one or more Aseba networks
-------------------------------------

.. GENERATED FROM PYTHON SOURCE LINES 19-23

.. code-block:: Python


    connection = client.connect("udp:")
    connection





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    1



.. GENERATED FROM PYTHON SOURCE LINES 24-26

Connections are positive integers that index connected
Dashel targets.

.. GENERATED FROM PYTHON SOURCE LINES 26-29

.. code-block:: Python


    client.connections





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    {1: 'udp:port=5000;address=0.0.0.0;sock=-1'}



.. GENERATED FROM PYTHON SOURCE LINES 30-42

3. Interact with the network[s]
-------------------------------
See the other examples.

4. Clean up
-----------

Once done, either close the connections one by one::

  client.close_connection(connection)

or close the client directly, which in turn closes all connections.

.. GENERATED FROM PYTHON SOURCE LINES 42-46

.. code-block:: Python


    client.close()
    client.connections





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    {}



.. GENERATED FROM PYTHON SOURCE LINES 47-53

.. hint::

   The client will automatically shutdown when it is deleted.
   Therefore, cleaning up is not strictly needed unless you want to release
   resources before the client is deleted,
   which would happen the latest when the script exits.


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.860 seconds)


.. _sphx_glr_download_gallery_client_1_connection.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: 1_connection.ipynb <1_connection.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: 1_connection.py <1_connection.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: 1_connection.zip <1_connection.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
