summaryrefslogtreecommitdiff
path: root/examples/dynamic_dispatch_table.lua
blob: 4d94fa235344e5f1a89660657dab28e05af44cda (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