diff options
Diffstat (limited to 'mom.lua')
-rw-r--r-- | mom.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mom.lua b/mom.lua index 86bfacc..4d14bd9 100644 --- a/mom.lua +++ b/mom.lua @@ -37,13 +37,19 @@ end -- create a new process in it -- returns process (unique id object), tx_queue, rx_queue -function mom.create(m, command) +-- you need to give it an identifier (this can be anything, and it isn't the id +-- that it uses internally). things pushed to the rx_queue will look like +-- { IDENTIFIER, "line", "meow" } +-- this is to make multiplexing easier +-- you must also give it a queue to send to (the rx_queue) +function mom.create(m, command, rx_id, rx_queue) local id = {} m.clients[id] = { - command = command, + command = assert(command), + rx_id = assert(rx_id), tx_queue = fifo.new(), - rx_queue = fifo.new(), + rx_queue = assert(rx_queue), tx_fds = fifo.new(), rx_fds = fifo.new(), } @@ -87,11 +93,11 @@ function mom.handle_from_ed(m, id) for inp in client.rx_fds:iter() do for line in inp:lines() do - client.rx_queue:put(line) + client.rx_queue:put({ client.rx_id, "line", line }) end inp:close() - client.rx_queue:put({ "quit" }) + client.rx_queue:put({ client.rx_id, "quit" }) end end |