OpenComputers Von Neumann Machine Programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
512 B

  1. local event = event or require("event") local modem = require("component").modem
  2. local http = {handlers = setmetatable({}, { __index = function() return function() end end }),
  3. handle = function(endpoint, f) http.handlers[endpoint] = f end,
  4. listen = function(port)
  5. modem.open(port)
  6. local eventID = event.listen("modem_message", function (...)
  7. if {...}[4] ~= port then return end
  8. http.handlers[{...}[6]](...)
  9. end)
  10. return eventID
  11. end,
  12. }