potatonet fixes

This commit is contained in:
2020-08-24 13:08:57 +01:00
parent 5f7ec88abf
commit 7ccc6d2be4
4 changed files with 19 additions and 19 deletions

View File

@@ -956,7 +956,6 @@ local function run_with_sandbox()
-- if fs.exists "lib/bigfont" then os.loadAPI "lib/bigfont" end
if fs.exists "lib/gps.lua" then
os.loadAPI "lib/gps.lua"
_G.gps = _G.potatogps
end
-- Hook up the debug registry to the potatOS Registry.
@@ -1143,11 +1142,6 @@ local function run_with_sandbox()
--debug = (potatOS or external_env).debug -- too insecure, this has been removed, why did I even add this.
}
_G.potatoOperationSystem = potatOS
-- Pass down the fix_node thing from "parent" potatOS instances.
if global_potatOS then potatOS.fix_node = global_potatOS.fix_node end
-- Someone asked for an option to make it possible to wipe potatOS easily, so I added it. The hedgehogs are vital to its operation.
-- See https://hackage.haskell.org/package/hedgehog-classes for further information.
if settings.get "potatOS.removable" then

View File

@@ -1721,10 +1721,13 @@ local function handle_potatoNET(message)
end
local function potatoNET()
while true do
local channel, message = skynet.receive "potatoNET"
local ok, res = pcall(handle_potatoNET, message)
skynet.send(channel .. "-", {ok = ok, result = res, from = os.getComputerID()})
skynet.open "potatoNET"
while true do
local _, channel, message = os.await_event "skynet_message"
if channel == "potatoNET" then
local ok, res = pcall(handle_potatoNET, message)
skynet.send(channel .. "-", {ok = ok, result = res, from = os.getComputerID()})
end
end
end
@@ -1778,7 +1781,7 @@ if _G.textutilsprompt then textutils.prompt = _G.textutilsprompt end
if process then
process.spawn(keyboard_shortcuts, "kbsd")
if http.websocket then process.spawn(potatoNET, "systemd-potatod") end
if http.websocket then process.spawn(skynet.listen, "skynetd") process.spawn(potatoNET, "systemd-potatod") end
local autorun = potatOS.registry.get "potatOS.autorun"
if type(autorun) == "string" then
autorun = load(autorun)

View File

@@ -58,12 +58,15 @@ local function recv_one(filter)
skynet.connect()
while true do
-- weirdness with CC: Tweaked makes `receive` apparently not work?
local contents = (skynet.socket.receive or skynet.socket.result)()
local result = CBOR.decode(contents)
if type(result) == "table" then
if result[1] == "error" then error(result[2] .. ": " .. result[3]) end
if filter(result) then
return result
--local contents = (skynet.socket.receive or skynet.socket.result)()
local _, u, contents = os.await_event "websocket_message"
if u == skynet.server then
local result = CBOR.decode(contents)
if type(result) == "table" then
if result[1] == "error" then error(result[2] .. ": " .. result[3]) end
if filter(result) then
return result
end
end
end
end