transport
Module¶
BaseServer Class¶
-
class
oscpython.transport.
BaseServer
(listen_address: Optional[oscpython.common.Client] = None, address_space: Optional[oscpython.address.AddressSpace] = None)[source]¶ Bases:
object
Base server class
- Parameters
listen_address – Value for
listen_address
. If not provided, defaults todefault_listen_address
address_space – Value for
address_space
. If not provided, an empty one will be created.
-
default_listen_address
: ClassVar[oscpython.common.Client] = Client(address='0.0.0.0', port=9000)¶ Default value for
listen_address
-
listen_address
: oscpython.common.Client¶ The address and port to bind the server to
-
property
address_space
¶ The
AddressSpace
associated with the server
-
property
message_handler
¶ The
MessageHandler
for the server
-
async
send_packet
(packet: oscpython.messages.Packet)[source]¶ Send either a
Message
orBundle
The
remote_client
in the given packet is used as the destination host address and port.- Parameters
packet – The packet to send
-
async
open
()[source]¶ Open the server connections and start all background tasks
Calls
open_endpoint()
and creates tasks fortx_loop()
andrx_loop()
.
-
async
close
()[source]¶ Stop all background tasks and close all connections
Calls
close_endpoint()
and stops thetx_loop()
andrx_loop()
tasks.
-
async
tx_loop
()[source]¶ Wait for items on
tx_queue
and send them usingsend_queue_item()
This runs as long as
running
is True and the task for it is managed by theopen()
andclose()
methods
-
async
rx_loop
()[source]¶ Wait for items on
rx_queue
and pass them tomessage_handler
usingMessageHandler.handle_packet()
.This runs as long as
running
is True and the task for it is managed by theopen()
andclose()
methods
-
async
open_endpoint
()[source]¶ Open implementation-specific items for communication
Called from the
open()
method
-
async
close_endpoint
()[source]¶ Close any implementation-specific communication items
Called from the
close()
method
-
async
send_queue_item
(item: oscpython.transport.QueueItem) → bool[source]¶ Handle transmission of a
QueueItem's
bytestring- Returns
True if the item was sent
- Return type
DatagramServer Class¶
-
class
oscpython.transport.
DatagramServer
(listen_address: Optional[oscpython.common.Client] = None, address_space: Optional[oscpython.address.AddressSpace] = None)[source]¶ Bases:
oscpython.transport.BaseServer
An OSC Client/Server using UDP
-
transport
: Optional[asyncio.transports.DatagramTransport]¶ Datagram transport created by
create_datagram_endpoint()
-
protocol
: Optional[oscpython.transport.DatagramProtocol]¶ Protocol created by
create_datagram_endpoint()
-
async
open_endpoint
()[source]¶ Open implementation-specific items for communication
Called from the
open()
method
-
async
close_endpoint
()[source]¶ Close any implementation-specific communication items
Called from the
close()
method
-
async
send_queue_item
(item: oscpython.transport.QueueItem) → bool[source]¶ Handle transmission of a
QueueItem's
bytestring- Returns
True if the item was sent
- Return type
-
DatagramProtocol Class¶
-
class
oscpython.transport.
DatagramProtocol
(rx_queue: asyncio.queues.Queue)[source]¶ Bases:
asyncio.protocols.DatagramProtocol
Asyncio
Protocol
for datagram communication
MessageHandler Class¶
-
class
oscpython.transport.
MessageHandler
(address_space: oscpython.address.AddressSpace)[source]¶ Bases:
object
Handles dispatching packets to an
AddressSpace
This is instanciated and managed by
BaseServer
- Parameters
address_space – The value for
address_space
-
address_space
: oscpython.address.AddressSpace¶ The
AddressSpace
for the handler
-
queued_bundles
: asyncio.queues.PriorityQueue¶ A queue for
QueuedBundle
items whosebundle_timetag
is in the future
-
async
handle_packet
(packet: oscpython.messages.Packet, timetag: oscpython.common.TimeTag)[source]¶ Handle an incoming
Packet
If the packet is a
Message
, theaddress_space
is searched for any matchingnodes
and thedispatch()
method will be called.If the packet is a
Bundle
, this method will be called recursively for all of thepackets
contained in the bundle.
-
async
dispatch_loop
()[source]¶ Consume from
queued_bundles
and dispatch them according to their timetagsThis runs as long as
running
is True and theasyncio.Task
for it is managed by theopen()
andclose()
methods.
QueueItem Class¶
-
class
oscpython.transport.
QueueItem
(data: bytes, addr: Tuple[str, int], timetag: oscpython.common.TimeTag = <factory>)[source]¶ Bases:
object
Item used in
BaseServer.rx_queue
andBaseServer.tx_queue
-
timetag
: oscpython.common.TimeTag¶ Timestamp of when the item was created
For incoming data, this indicates the time of reception
-
QueuedBundle Class¶
-
class
oscpython.transport.
QueuedBundle
(bundle_timetag: oscpython.common.TimeTag, rx_timetag: Optional[oscpython.common.TimeTag], bundle: Optional[oscpython.messages.Bundle])[source]¶ Bases:
object
Item to store bundles in a
asyncio.PriorityQueue
sorted bybundle_timetag
-
bundle_timetag
: oscpython.common.TimeTag¶ The
timetag
value of thebundle
. This is duplicated solely for sorting purposes
-
rx_timetag
: Optional[oscpython.common.TimeTag]¶ The timestamp of when the bundle was received
-
bundle
: Optional[oscpython.messages.Bundle]¶ The
Bundle
instance
-