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

local event = event or require("event") local modem = require("component").modem
local http = {handlers = setmetatable({}, { __index = function() return function() end end }),
handle = function(endpoint, f) http.handlers[endpoint] = f end,
listen = function(port)
modem.open(port)
local eventID = event.listen("modem_message", function (...)
if {...}[4] ~= port then return end
http.handlers[{...}[6]](...)
end)
return eventID
end,
}