mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2025-01-02 16:03:48 +01:00
use accessManager.hasControl. Fixes issue #75
This commit is contained in:
parent
c536fe3221
commit
fdbc07b377
@ -224,30 +224,22 @@ local function addSequenceNumbering(printer, response)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.fetch_POST(request, response)
|
function M.fetch_POST(request, response)
|
||||||
local printer,msg = printerUtils.createPrinterOrFail(argId, response)
|
if not accessManager.hasControl(request.remoteAddress) then
|
||||||
if not printer or not printer:hasSocket() then return end
|
|
||||||
|
|
||||||
local controllerIP = accessManager.getController()
|
|
||||||
local hasControl = false
|
|
||||||
if controllerIP == "" then
|
|
||||||
accessManager.setController(request.remoteAddress)
|
|
||||||
hasControl = true
|
|
||||||
elseif controllerIP == request.remoteAddress then
|
|
||||||
hasControl = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if not hasControl then
|
|
||||||
response:setFail("No control access")
|
response:setFail("No control access")
|
||||||
return
|
return
|
||||||
|
else
|
||||||
|
accessManager.setController(request.remoteAddress)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local printer,msg = printerUtils.createPrinterOrFail(argId, response)
|
||||||
|
if not printer or not printer:hasSocket() then return end
|
||||||
|
|
||||||
local state = printer:getState()
|
local state = printer:getState()
|
||||||
if state ~= "idle" then
|
if state ~= "idle" then
|
||||||
response:setFail("printer is not idle")
|
response:setFail("printer is not idle")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
log:verbose(MOD_ABBR, " clearing all gcode for " .. printer:getId())
|
log:verbose(MOD_ABBR, " clearing all gcode for " .. printer:getId())
|
||||||
stopFetch()
|
stopFetch()
|
||||||
local rv,msg = printer:clearGcode()
|
local rv,msg = printer:clearGcode()
|
||||||
@ -281,7 +273,6 @@ function M.fetch_POST(request, response)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
endCodeFile:write(endCode)
|
endCodeFile:write(endCode)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local socket = printer:getId()
|
local socket = printer:getId()
|
||||||
@ -318,20 +309,12 @@ end
|
|||||||
-- a fail with a (formal, i.e., parseable) status argument will be returned;
|
-- a fail with a (formal, i.e., parseable) status argument will be returned;
|
||||||
-- additionally, current sequence number and total will be returned (both are -1 if they have not been set)
|
-- additionally, current sequence number and total will be returned (both are -1 if they have not been set)
|
||||||
function M.print_POST(request, response)
|
function M.print_POST(request, response)
|
||||||
local controllerIP = accessManager.getController()
|
if not accessManager.hasControl(request.remoteAddress) then
|
||||||
local hasControl = false
|
|
||||||
if controllerIP == "" then
|
|
||||||
accessManager.setController(request.remoteAddress)
|
|
||||||
hasControl = true
|
|
||||||
elseif controllerIP == request.remoteAddress then
|
|
||||||
hasControl = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if not hasControl then
|
|
||||||
response:setFail("No control access")
|
response:setFail("No control access")
|
||||||
return
|
return
|
||||||
|
else
|
||||||
|
accessManager.setController(request.remoteAddress)
|
||||||
end
|
end
|
||||||
|
|
||||||
local argId = request:get("id")
|
local argId = request:get("id")
|
||||||
local argGcode = request:get("gcode")
|
local argGcode = request:get("gcode")
|
||||||
local argClear = utils.toboolean(request:get("clear"))
|
local argClear = utils.toboolean(request:get("clear"))
|
||||||
|
Loading…
Reference in New Issue
Block a user