diff options
author | Dan <dan@rcoh-ubuntu-small.(none)> | 2011-01-25 13:48:39 -0500 |
---|---|---|
committer | Dan <dan@rcoh-ubuntu-small.(none)> | 2011-01-25 13:48:39 -0500 |
commit | 7557819216cd7d9acd9a4f97d686d6ec84740655 (patch) | |
tree | e106050838b37757b1d7b10681c4436d9e2af9df | |
parent | eaaef5460a95d2de1dddc847f6c3bbcb2aef8047 (diff) |
renamed osc server for test
-rwxr-xr-x | testosc.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/testosc.py b/testosc.py new file mode 100755 index 0000000..6763f41 --- /dev/null +++ b/testosc.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import liblo, sys + +# create server, listening on port 1234 +try: + server = liblo.Server(1234) +except liblo.ServerError, err: + print str(err) + sys.exit() + +def foo_bar_callback(path, args): + i, f = args + print "received message '%s' with arguments '%d' and '%f'" % (path, i, f) + +def foo_baz_callback(path, args, types, src, data): + print "received message '%s'" % path + print "blob contains %d bytes, user data was '%s'" % (len(args[0]), data) + +def fallback(path, args, types, src): + print "got unknown message '%s' from '%s'" % (path, src.get_url()) + for a, t in zip(args, types): + print "argument of type '%s': %s" % (t, a) + +# register method taking an int and a float +server.add_method("/foo/bar", 'if', foo_bar_callback) + +# register method taking a blob, and passing user data to the callback +server.add_method("/foo/baz", 'b', foo_baz_callback, "blah") + +# register a fallback for unhandled messages +server.add_method(None, None, fallback) + +# loop and dispatch messages every 100ms +while True: + server.recv(100) |