aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Daniel <dmt@daniel-desktop.(none)>2011-01-29 18:54:50 -0800
committerGravatar Daniel <dmt@daniel-desktop.(none)>2011-01-29 18:54:50 -0800
commitff07b18748c64243c1c6bc62f489bfd03205d13a (patch)
treedb95373a3511be0dd1e700a78e9f1ea7320769a4 /tests
parent83931a3c8e65b4018e98b4986458d1df7172ab91 (diff)
parent277a5143165d2553ce5e97f151cc6b3cea426468 (diff)
Merge branch 'master' of github.com:rcoh/SmootLight
Diffstat (limited to 'tests')
-rwxr-xr-xtests/testosc.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/testosc.py b/tests/testosc.py
new file mode 100755
index 0000000..6763f41
--- /dev/null
+++ b/tests/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)