OscDispatcher

class supriya.tools.osctools.OscDispatcher[source]

An OSC message dispatcher.

>>> from supriya import osctools
>>> dispatcher = osctools.OscDispatcher()
>>> osc_callback = osctools.OscCallback(
...     address_pattern='/*',
...     procedure=lambda x: print('GOT:', x),
...     )
>>> dispatcher.register_callback(osc_callback)
>>> message = osctools.OscMessage('/okay', 1, 2, 3)
>>> dispatcher(message)
GOT: size 28
   0   2f 6f 6b 61  79 00 00 00  2c 69 69 69  00 00 00 00   |/okay...,iii....|
  16   00 00 00 01  00 00 00 02  00 00 00 03                |............|
>>> dispatcher.unregister_callback(osc_callback)
>>> dispatcher(message)

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=1, group=0, label=object, shape=box]; } subgraph cluster_osctools { graph [label=osctools]; "supriya.tools.osctools.OscDispatcher.OscDispatcher" [color=black, fontcolor=white, group=1, label=<<B>OscDispatcher</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_systemtools { graph [label=systemtools]; "supriya.tools.systemtools.SupriyaObject.AbstractBase" [color=3, group=2, label=AbstractBase, shape=box]; "supriya.tools.systemtools.SupriyaObject.SupriyaObject" [color=3, group=2, label=SupriyaObject, shape=box]; "supriya.tools.systemtools.SupriyaObject.AbstractBase" -> "supriya.tools.systemtools.SupriyaObject.SupriyaObject"; } "builtins.object" -> "supriya.tools.systemtools.SupriyaObject.AbstractBase"; "supriya.tools.systemtools.SupriyaObject.SupriyaObject" -> "supriya.tools.osctools.OscDispatcher.OscDispatcher"; }

Bases

Attribute summary

compile_address_pattern(pattern)
register_callback(osc_callback) Registers osc_callback.
unregister_callback(osc_callback) Unregisters osc_callback.
__call__(message) Handles message.
__eq__(expr) Is true when ID of expr equals ID of Supriya object.
__format__([format_specification]) Formats Supriya object.
__hash__() Hashes Supriya object.
__repr__() Gets interpreter representation of Supriya object.

Methods

OscDispatcher.register_callback(osc_callback)[source]

Registers osc_callback.

Returns none.

OscDispatcher.unregister_callback(osc_callback)[source]

Unregisters osc_callback.

Returns none.

Class & static methods

static OscDispatcher.compile_address_pattern(pattern)[source]

Special methods

OscDispatcher.__call__(message)[source]

Handles message.

Finds all matching callbacks and passes the message to each.

Returns none.

(SupriyaObject).__eq__(expr)

Is true when ID of expr equals ID of Supriya object. Otherwise false.

Returns boolean.

(SupriyaObject).__format__(format_specification='')

Formats Supriya object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(SupriyaObject).__hash__()

Hashes Supriya object.

Required to be explicitely re-defined on Python 3 if __eq__ changes.

Returns integer.

(SupriyaObject).__repr__()

Gets interpreter representation of Supriya object.

Returns string.