Net::LibLO - Perl interface for liblo Lightweight OSC library
use Net::LibLO;
my $lo = new Net::LibLO( );
$lo->add_method( "/reply", 's', \&my_handler );
$lo->send( 'osc://localhost:5600/', '/foo/bar', 's', 'Hello World' );
Net::LibLO class is used to send and recieve OSC messages using LibLO (the
Lightweight OSC library). The coding style is slightly different to the C
interface to LibLO, because it makes use of perl's Object Oriented
functionality.
- new( [port], [protocol] )
- Create a new LibLO object for sending a recieving messages. If the
"port" is missing, then a random port
number is chosen. If the "protocol" is
missing, than UDP is used.
- send( dest, bundle )
- Send a bundle to the sepecified destination.
"dest" can either be a
Net::LibLO::Address object, a URL or a port.
"bundle" should be a
Net::LibLO::Bundle object.
- send( dest, path, message )
- Send a message to the sepecified destination.
"dest" can either be a
Net::LibLO::Address object, a URL or a port.
"message" should be a
Net::LibLO::Message object.
- send( dest, path, typespec, params... )
- Construct and send a message to the sepecified destination.
"dest" can either be a
Net::LibLO::Address object, a URL or a port.
"path" is the path to send
the message to.
"typespec" and
"params" are passed through to create
the new message.
- recv()
- Block and wait to receive a single message. Returns the length of the
message in bytes or number less than 1 on failure. Length of message is
returned, whether the message has been handled by a method or not.
- recv_noblock( [timeout] )
- Look for an OSC message waiting to be received. Waits for
"timeout" milliseconds for a message and
then returns the length of the message, or 0 if there was no message. Use
a value of 0 to return immediatly.
- add_method( path, typespec, handler, userdata )
- Add an OSC method to the specifed server.
"path" is the OSC path to
register the method to. If "undef" is
passed the method will match all paths.
"typespec" is OSC typespec
that the method accepts. Incoming messages with similar typespecs (e.g.
ones with numerical types in the same position) will be coerced to the
typespec given here.
"handler" is a reference to
the method handler callback subroutine that will be called if a matching
message is received.
"user_data" is a value that
will be passed to the callback subroutine, when its invoked matching
from this method.
- my_handler( serv, mesg, path, typespec, userdata, @params
)
- This is order of parameters that will be passed to your method handler
subroutines.
"serv" is the Net::LibLO
object that the method is registered with.
"mesg" is a
Net::LibLO::Message object for the incoming message.
"path" is the path the
incoming message was sent to.
"typespec" If you specided
types in your method creation call then this will match those and the
incoming types will have been coerced to match, otherwise it will be the
types of the arguments of the incoming message.
"userdata" This contains the
userdata value passed in the call to
"add_method"
"params" is an array of
values associated with the message
- get_port()
- Returns the port the socket is bound to.
- get_url()
- Returns the full URL for talking to this server.
Net::LibLO::Address
Net::LibLO::Bundle
Net::LibLO::Message
<http://liblo.sourceforge.net/>
Nicholas J. Humfrey <njh@aelius.com>
Copyright (C) 2005 Nicholas J. Humfrey
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.