udp: reply with tag/module in msg
s-ol
2 years ago
34 | 34 | switch msg.type |
35 | 35 | when 'tick' |
36 | 36 | res.tick = @copilot.T |
37 | -- when 'sub' | |
38 | -- @subs[client] = true | |
39 | -- res.ok = true | |
40 | -- when 'unsub' | |
41 | -- @subs[client] = nil | |
42 | -- res.ok = true | |
43 | 37 | when 'modules' |
44 | 38 | res.modules = [name for name in pairs @copilot.last_modules] |
45 | 39 | when 'info' |
46 | mod = @copilot.last_modules[msg.module or '__root'] | |
40 | res.tag = msg.tag | |
41 | res.module = msg.module or '__root' | |
42 | mod = @copilot.last_modules[res.module] | |
47 | 43 | builtin = mod.registry\last msg.tag |
48 | 44 | if builtin and builtin.__class.__name ~= 'DummyReg' |
49 | 45 | res.head_meta = builtin.head.meta |
55 | 51 | else |
56 | 52 | res.error = 'not_registered' |
57 | 53 | when 'state' |
58 | mod = @copilot.last_modules[msg.module or '__root'] | |
54 | res.tag = msg.tag | |
55 | res.module = msg.module or '__root' | |
56 | mod = @copilot.last_modules[res.module] | |
59 | 57 | builtin = mod.registry\last msg.tag |
60 | 58 | if builtin and builtin.__class.__name ~= 'DummyReg' |
61 | 59 | res.value = encode_res builtin.node.result, @copilot |
62 | if op = builtin.op | |
63 | res.state = op.state | |
60 | res.state = if builtin.op then builtin.op.state | |
64 | 61 | else |
65 | 62 | res.error = 'not_registered' |
66 | 63 | else |