transport Module¶
BaseServer Class¶
-
class
oscpython.transport.BaseServer(listen_address: Optional[oscpython.common.Client] = None, address_space: Optional[oscpython.address.AddressSpace] = None)[source]¶ Bases:
objectBase server class
- Parameters
listen_address – Value for
listen_address. If not provided, defaults todefault_listen_addressaddress_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
AddressSpaceassociated with the server
-
property
message_handler¶ The
MessageHandlerfor the server
-
async
send_packet(packet: oscpython.messages.Packet)[source]¶ Send either a
MessageorBundleThe
remote_clientin 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_queueand send them usingsend_queue_item()This runs as long as
runningis True and the task for it is managed by theopen()andclose()methods
-
async
rx_loop()[source]¶ Wait for items on
rx_queueand pass them tomessage_handlerusingMessageHandler.handle_packet().This runs as long as
runningis 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'sbytestring- 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.BaseServerAn 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'sbytestring- Returns
True if the item was sent
- Return type
-
DatagramProtocol Class¶
-
class
oscpython.transport.DatagramProtocol(rx_queue: asyncio.queues.Queue)[source]¶ Bases:
asyncio.protocols.DatagramProtocolAsyncio
Protocolfor datagram communication
MessageHandler Class¶
-
class
oscpython.transport.MessageHandler(address_space: oscpython.address.AddressSpace)[source]¶ Bases:
objectHandles dispatching packets to an
AddressSpaceThis is instanciated and managed by
BaseServer- Parameters
address_space – The value for
address_space
-
address_space: oscpython.address.AddressSpace¶ The
AddressSpacefor the handler
-
queued_bundles: asyncio.queues.PriorityQueue¶ A queue for
QueuedBundleitems whosebundle_timetagis in the future
-
async
handle_packet(packet: oscpython.messages.Packet, timetag: oscpython.common.TimeTag)[source]¶ Handle an incoming
PacketIf the packet is a
Message, theaddress_spaceis searched for any matchingnodesand thedispatch()method will be called.If the packet is a
Bundle, this method will be called recursively for all of thepacketscontained in the bundle.
-
async
dispatch_loop()[source]¶ Consume from
queued_bundlesand dispatch them according to their timetagsThis runs as long as
runningis True and theasyncio.Taskfor 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:
objectItem used in
BaseServer.rx_queueandBaseServer.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:
objectItem to store bundles in a
asyncio.PriorityQueuesorted bybundle_timetag-
bundle_timetag: oscpython.common.TimeTag¶ The
timetagvalue 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
Bundleinstance
-