Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local App = app.new(...)
- local Apps = App:load(".apps")
- function App:handleMessage(sender, req, protocol)
- if protocol ~= "appstore" then return end
- local resp = nil
- if req.Protocol == "get" then resp = App:get(req)
- elseif req.Protocol == "post" then resp = App:post(req)
- end
- if resp then rednet.send(sender, resp, "appstore") end
- end
- function App:get(req)
- return {Type="apps",Data=Apps}
- end
- function App:post(req)
- App:download(req.Code, "temp.manifest")
- Apps[req.Code] = App:load("temp.manifest")
- App:delete("temp.manifest")
- App:save(".apps", Apps)
- rednet.broadcast({Type="app",Data={Code=req.Code,Manifest=Apps[req.Code]}}, "appstore")
- end
- function App:draw()
- end
- function App:stopped()
- App:save(".apps", Apps)
- end
- App.EventHandler:connect("rednet_message", function(...) App:handleMessage(...) end)
- rednet.host("appstore", "server")
- App:start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement