summaryrefslogtreecommitdiff
path: root/examples/dynamic_dispatch_table.lua
blob: 38b8bae4ffa6e7b74a5393564cfdc2fcb387ed74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}

local responses = {
   [".*\n"] = function(match) end
}

return get_length_table, responses