Webserver memory optimization with local variables
This commit is contained in:
parent
54095e7c20
commit
da139e3412
@ -1,8 +1,7 @@
|
|||||||
--TODO:
|
-- Webserver
|
||||||
configFile="config.lua"
|
local configFile="config.lua"
|
||||||
|
local httpSending=false
|
||||||
httpSending=false
|
local sentBytes=0
|
||||||
sentBytes=0
|
|
||||||
function sendPage(conn, nameOfFile, replaceMap)
|
function sendPage(conn, nameOfFile, replaceMap)
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("Sending " .. nameOfFile .. " " .. sentBytes .. "B already; " .. node.heap() .. "B in heap")
|
print("Sending " .. nameOfFile .. " " .. sentBytes .. "B already; " .. node.heap() .. "B in heap")
|
||||||
@ -127,22 +126,6 @@ function fillDynamicMap()
|
|||||||
return replaceMap
|
return replaceMap
|
||||||
end
|
end
|
||||||
|
|
||||||
function stopWordclock()
|
|
||||||
print("Stop all Wordclock")
|
|
||||||
-- Stop all
|
|
||||||
-- unload all other functions
|
|
||||||
-- grep function *.lua | grep -v webserver | grep -v init.lua | grep -v main.lua | cut -f 2 -d ':' | grep "^function" | sed "s/function //g" | grep -o "^[a-zA-Z0-9\_]*"
|
|
||||||
updateColor = nil
|
|
||||||
drawLEDs = nil
|
|
||||||
round = nil
|
|
||||||
generateLEDs = nil
|
|
||||||
isSummerTime = nil
|
|
||||||
getUTCtime = nil
|
|
||||||
getTime = nil
|
|
||||||
display_timestat = nil
|
|
||||||
collectgarbage()
|
|
||||||
end
|
|
||||||
|
|
||||||
function startWebServer()
|
function startWebServer()
|
||||||
srv=net.createServer(net.TCP)
|
srv=net.createServer(net.TCP)
|
||||||
srv:listen(80,function(conn)
|
srv:listen(80,function(conn)
|
||||||
@ -153,7 +136,6 @@ function startWebServer()
|
|||||||
end
|
end
|
||||||
if (payload:find("GET /") ~= nil) then
|
if (payload:find("GET /") ~= nil) then
|
||||||
httpSending=true
|
httpSending=true
|
||||||
stopWordclock()
|
|
||||||
if (color == nil) then
|
if (color == nil) then
|
||||||
color=string.char(0,128,0)
|
color=string.char(0,128,0)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user