1 Star 0 Fork 0

missyoyo/MoonGUI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
moongui.lua 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
WiednerF 提交于 2017-01-13 12:50 . Changed Speed of Application
local json = require "dkjson"
local turbo = require "turbo"
local moongui = {}
-- Source stackoverflow.com
function moongui.subrange(t,first)
local sub = {}
local i = first
while #t>=i and ((i-first)<=1500) do
sub[#sub + 1] = t[i]
i = i +1
end
return sub
end
function moongui.getConfig(execution)
local configFile = assert(io.open("history/"..execution.."/config.json"))
local configString = configFile:read("*all")
local config = json.decode(configString,1,nil)
return config
end
function moongui.server(p,mg)
local dataStorage = {}
local MoonGenDataHandler = class("MoonGenDataHandler",turbo.web.RequestHandler)
function MoonGenDataHandler:get()--TODO Test
local count = tonumber(self:get_argument("count","0"))
local data = moongui.subrange(dataStorage,count)
self:write({count=(#data+count),data=data})
end
turbo.web.Application({
{"^/data/$",MoonGenDataHandler}
}):listen(4999)
local ioloop = turbo.ioloop.instance()
ioloop:set_interval(300, function()
if not mg.running() then
ioloop:close()
end
end
)
ioloop:set_interval(100, function()
local a = p:tryRecv(0)
local i=0
while a~=nil and i<50 do
table.insert(dataStorage,a)
if i<50 then
a=p:tryRecv(0)
end
end
end
)
ioloop:start()
end
return moongui
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/missyoyo/MoonGUI.git
git@gitee.com:missyoyo/MoonGUI.git
missyoyo
MoonGUI
MoonGUI
moonGUI

搜索帮助