Skip to content

Commit 91820f7

Browse files
authored
Update README.rst
1 parent 138ccdb commit 91820f7

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

README.rst

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ aiosc requires at least Python 3.7. It can be installed using pip::
1313

1414
pip3 install aiosc
1515

16-
Alternatively, use ``--user`` option to install aiosc for the current user::
16+
Alternatively, use ``--user`` option to install aiosc only for the current user::
1717

1818
pip3 install --user aiosc
1919

@@ -23,8 +23,9 @@ Usage
2323
To send OSC messages with ``aiosc``, create an asyncio datagram connection
2424
endpoint using ``aiosc.OSCProtocol`` as the protocol factory.
2525

26-
A datagram connection can be created with ``loop.create_datagram_endpoint``
27-
method as follows:
26+
A datagram connection can be created with the ``create_datagram_endpoint``
27+
method of the asyncio event loop. Use the argument ``remote_addr`` to specify
28+
the OSC server address and port as follows:
2829

2930
.. code-block:: python
3031
@@ -37,17 +38,29 @@ method as follows:
3738
transport, osc = await loop.create_datagram_endpoint(aiosc.OSCProtocol,
3839
remote_addr=('127.0.0.1', 8000))
3940
40-
osc.send('/hello', 'world')
41-
osc.send('/goodbye', 'cruel', 'world')
41+
osc.send('/hello/world')
42+
osc.send('/a/b/cde', 1000, -1, 'hello', 1.234, 5.678)
4243
4344
asyncio.run(main())
4445
4546
For an OSC server implementation, ``aiosc.OSCProtocol`` can be subclassed
46-
or directly constructed with a dictionary mapping OSC address patterns to
47-
handler methods for incoming messages:
47+
or directly constructed with a dictionary which maps OSC address patterns to
48+
handler methods for incoming messages.
49+
50+
When creating datagram connection for an OSC server with
51+
``create_datagram_endpoint``, use the argument ``local_addr`` to specify
52+
the interface (address) and listening port for the server.
53+
54+
In a typical case, local address can look like ``('0.0.0.0', 9000)`` where
55+
``9000`` is the port number and ``0.0.0.0`` address designates that the server
56+
will be listening on all available network interfaces.
4857

4958
.. code-block:: python
5059
60+
import asyncio
61+
import aiosc
62+
import sys
63+
5164
class EchoServer(aiosc.OSCProtocol):
5265
def __init__(self):
5366
super().__init__(handlers={
@@ -62,7 +75,7 @@ handler methods for incoming messages:
6275
loop = asyncio.get_running_loop()
6376
6477
transport, osc = await loop.create_datagram_endpoint(EchoServer,
65-
local_addr=('127.0.0.1', 9000))
78+
local_addr=('0.0.0.0', 8000))
6679
6780
await loop.create_future()
6881

0 commit comments

Comments
 (0)