summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Grueneis <gimpf@spreadspace.org>2010-11-24 22:39:16 +0000
committerMarkus Grueneis <gimpf@spreadspace.org>2010-11-24 22:39:16 +0000
commit8630f69b165553b1c343f065bfd314ef43f78c84 (patch)
treeea33c87f82902a35b5cd86939201e2395bf22ce0
parentdebugged dispatch table (diff)
added example gcsd startup script, and example dispatch-table for simple binary protocol
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@62 ac14a137-c7f1-4531-abe0-07747231d213
-rw-r--r--examples/dynamic_dispatch_table.lua16
-rw-r--r--examples/start_gcsd.sh7
2 files changed, 23 insertions, 0 deletions
diff --git a/examples/dynamic_dispatch_table.lua b/examples/dynamic_dispatch_table.lua
new file mode 100644
index 0000000..c515621
--- /dev/null
+++ b/examples/dynamic_dispatch_table.lua
@@ -0,0 +1,16 @@
+local get_length_table = {
+ [".."] = function(match)
+ local bytes = string.byte(match, 1, 2)
+ local length = bytes[1] * 256^2 + bytes[2] -- TODO byte order?
+ local get_binary_data_table = {
+ [string.rep(".", length)] = function(match)
+ command_queue:enqueue(match)
+ dispatch_table:register_handler_table(get_length_table)
+ end
+ }
+
+ dispatch_table:register_handler_table(get_binary_data_table)
+ end
+}
+
+return get_length_table
diff --git a/examples/start_gcsd.sh b/examples/start_gcsd.sh
new file mode 100644
index 0000000..9f315c7
--- /dev/null
+++ b/examples/start_gcsd.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# -U debug-mode (starts debug module)
+# -o start stdio as output module
+# -i start dummy as input module
+# -l use specified file as dispatch-table configuration
+gcsd -U -o stdio:name=stdio -i dummy:name=dumm -l tmp.lua