aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-01 17:34:26 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-01 17:34:26 +0000
commit16d3cae5d3c3b03cbce26e0c897b28102a86795a (patch)
treefc18eb870c6047b95da817865c551b846db01a15
parentmodularize (diff)
downloadalive-16d3cae5d3c3b03cbce26e0c897b28102a86795a.tar.gz
alive-16d3cae5d3c3b03cbce26e0c897b28102a86795a.zip
add osc
-rw-r--r--init.moon1
-rw-r--r--lib/osc.moon21
2 files changed, 22 insertions, 0 deletions
diff --git a/init.moon b/init.moon
index c028e50..c9536de 100644
--- a/init.moon
+++ b/init.moon
@@ -4,6 +4,7 @@ env = Registry!
env\add_module 'math'
env\add_module 'time'
env\add_module 'util'
+env\add_module 'osc'
env\add_module 'debug'
if ... == 'init'
diff --git a/lib/osc.moon b/lib/osc.moon
new file mode 100644
index 0000000..a99aab0
--- /dev/null
+++ b/lib/osc.moon
@@ -0,0 +1,21 @@
+import Op from require 'base'
+import pack, unpack from require 'osc'
+import dns, udp from require 'socket'
+
+class out extends Op
+ new: (...) =>
+ super ...
+
+ @@udp or= udp!
+
+ setup: (@host, @port, @path, @value) =>
+
+ update: =>
+ ip = dns.toip @host\get!
+ port = @port\get!
+ msg = pack @path\get!, @value\get!
+ @@udp\sendto msg, ip, port
+
+{
+ :out
+}