Skip to content

Commit

Permalink
Update README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
artfwo committed Apr 14, 2023
1 parent b880c11 commit 138ccdb
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,36 @@ aiosc requires at least Python 3.7. It can be installed using pip::

pip3 install aiosc

Or use ``--user`` option to install aiosc locally::
Alternatively, use ``--user`` option to install aiosc for the current user::

pip3 install --user aiosc

Usage
=====

To send an OSC message just use ``aiosc.send``:
To send OSC messages with ``aiosc``, create an asyncio datagram connection
endpoint using ``aiosc.OSCProtocol`` as the protocol factory.

A datagram connection can be created with ``loop.create_datagram_endpoint``
method as follows:

.. code-block:: python
import asyncio
import aiosc
async def main():
await aiosc.send(('127.0.0.1', 9000), '/hello', 'world')
loop = asyncio.get_running_loop()
transport, osc = await loop.create_datagram_endpoint(aiosc.OSCProtocol,
remote_addr=('127.0.0.1', 8000))
osc.send('/hello', 'world')
osc.send('/goodbye', 'cruel', 'world')
asyncio.run(main())
To implement an OSC server with ``aiosc`` you should create an UDP endpoint
using ``aiosc.OSCProtocol`` as the protocol. ``OSCProtocol`` can be subclassed
For an OSC server implementation, ``aiosc.OSCProtocol`` can be subclassed
or directly constructed with a dictionary mapping OSC address patterns to
handler methods for incoming messages:

Expand All @@ -51,7 +60,8 @@ handler methods for incoming messages:
async def main():
loop = asyncio.get_running_loop()
transport, protocol = await loop.create_datagram_endpoint(EchoServer,
transport, osc = await loop.create_datagram_endpoint(EchoServer,
local_addr=('127.0.0.1', 9000))
await loop.create_future()
Expand Down

0 comments on commit 138ccdb

Please sign in to comment.