pyliblo - API Documentation

import liblo

Server

Server([port])

Constructs a new Server object, which can receive OSC messages.
port may be a decimal port number or a UNIX socket path. If omitted, a random free UDP port will be used.
Exceptions: ServerError

get_url()

Returns the server's URL.

get_port()

Returns the server's port number.

add_method(path, typespec, callback_func[, user_data])

Registers a callback function for OSC messages with matching path and argument types.
For both path and typespec, None may be used as a wildcard.
The optional user_data will be passed on to the callback function. callback_func may be a global function or a class method, pyliblo will know what to do either way.

my_callback(path, args[, src[, user_data]])
my_callback(self, path, args[, src[, user_data]])

User-defined callback function, to be registered using add_method(); called when a matching OSC message is received.
args will be a list of objects of type Argument, each containing the argument's typespec and data, which can be accessed through args[n].type and args[n].value, respectively.
src is an Address object, containing the address the message came from. src and user_data may be omitted if not needed.

recv([timeout])

Receives and dispatches an OSC message. Blocking by default, unless timeout (in ms) is specified.
timeout may be 0, in which case recv() returns immediately. Returns True if a message was received, False otherwise.

send(target, message)
send(target, path[, arg, ...])

Sends a message from this server to the the given target.
target may be an Address object, a port number, a (hostname,port) tuple, or a URL. See Message for possible argument types.
Exceptions: AddressError

Address

Address(hostname, port)
Address(port)
Address(url)

Constructs a new Address object from the given hostname/port or URL.
Exceptions: AddressError

get_url()

Returns the address' URL.

get_hostname()

Returns the address' hostname.

get_port()

Returns the address' port number.

Message

Message(path[, arg, ...])

Constructs a new Message object.

add(arg[, ...])

Appends the given argument(s) to the message.

Argument types:

Each argument may be an int, float, string, or a (typespec,data) tuple to allow for greater control over the type to be transmitted.

data typetypespecargument
int32'i'int
int64'h'int, long
float'f'float
double'd'float
char'c'single-character string
string's'string
blob'b'list, tuple, array.array('B')

Functions

send(target, message)
send(target, path[, arg, ...])

Sends a message to the the given target, without requiring a server.
target may be an Address object, a port number, a (hostname,port) tuple, or a URL. See Message for possible argument types.
Exceptions: AddressError