pyliblo 0.5 - API Documentation

import liblo

class 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, an arbitrary free UDP port will be used.
Exceptions: ServerError

recv([timeout])

Receives and dispatches one 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.

class ServerThread

ServerThread([port])

Constructs a new ServerThread object.
Unlike Server, ServerThread uses its own thread which runs in the background to dispatch messages. Note that callback methods will not be run in the main Python thread!
Exceptions: ServerError

start()

Starts the server thread, liblo will now start to dispatch any messages it receives.

stop()

Stops the server thread.

common methods of both Server and ServerThread

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[, types[, src[, user_data]]])
my_callback(self, path, args[, types[, 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 message arguments, using appropriate built-in Python data types. blobs are passed as lists of integers. types is a string with the typespec of the message.
src is an Address object, containing the address the message came from. types, src and user_data may be omitted if not needed.

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

class 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.

class 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, long, float, string, any sequence type, 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'sequence (list, tuple, array.array('B'), ...)

top-level 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