-- 通信部分
local http_server = HttpServer():onGet("/info", function(req, res) -- 信息
-- log("get info")
local info = {
message = "OK",
status = 200,
data = {
player = {}
}
}
for i, p in pairs(mc.getOnlinePlayers()) do
table.insert(info.data.player, p.name)
end
res.status = 200
res.reason = "OK"
res.body = data.toJson(info)
res:setHeader("Content-Type", "application/json")
return false
end):onPost("/command", function(req, res) -- 命令
res.status = 200
res.reason = "OK"
res:write("[]")
res:setHeader("Content-Type", "application/json")
return false
end):onGet("/", function(req, res)
res.status = 200
res.reason = "OK"
res:write("/info\n/command\n/message")
res:setHeader("Content-Type", "text/html")
return false
end):listen("127.0.0.1", 56803)
有关的日志/输出
No response
插件列表
14:21:37 INFO [Server] 插件列表 [8]
14:21:37 INFO [Server] - LLMoney [v2.9.0]
(LLMoney.dll)
14:21:37 INFO [Server] EconomyCore for LiteLoaderBDS
14:21:37 INFO [Server] - ScriptEngine-Lua [v2.9.0]
(LiteLoader.Lua.dll)
14:21:37 INFO [Server] Lua ScriptEngine for LiteLoaderBDS
14:21:37 INFO [Server] - BehaviorLog [v0.0.1]
(behavior_log.lua)
14:21:37 INFO [Server] 玩家行为日志
14:21:37 INFO [Server] - PHP [v0.0.2] (PH
P.lua)
14:21:37 INFO [Server] PHP-Server
14:21:37 INFO [Server] - PermissionAPI [v2.9.0]
(PermissionAPI.dll)
14:21:37 INFO [Server] Builtin & Powerful permission API for LiteLoaderBDS
14:21:37 INFO [Server] - PSG [v0.0.2] (ga
me.lua)
14:21:37 INFO [Server] PHP-Server-Game
14:21:37 INFO [Server] - ScriptEngine-QuickJs [v2.9.0]
(LiteLoader.Js.dll)
14:21:37 INFO [Server] Javascript ScriptEngine for LiteLoaderBDS
14:21:37 INFO [Server] - ScriptEngine-NodeJs [v2.9.0]
(LiteLoader.NodeJs.dll)
14:21:37 INFO [Server] Node.js ScriptEngine for LiteLoaderBDS
14:21:37 INFO [Server]
14:21:37 INFO [Server]
14:21:37 INFO [Server] * 使用命令“ll list <Plugin Name>”来获取更多信息
异常模块
ScriptEngine (脚本引擎)
操作系统
GNU/Linux with wine
LiteLoader 版本
2.9.0
BDS 版本
1.19.51
发生了什么?
Lua 插件的 HttpServer 使用 listen 或 startAt 开启监听后,get两次就无法连接了
复现此问题的步骤
-- 通信部分 local http_server = HttpServer():onGet("/info", function(req, res) -- 信息 -- log("get info") local info = { message = "OK", status = 200, data = { player = {} } } for i, p in pairs(mc.getOnlinePlayers()) do table.insert(info.data.player, p.name) end res.status = 200 res.reason = "OK" res.body = data.toJson(info) res:setHeader("Content-Type", "application/json") return false end):onPost("/command", function(req, res) -- 命令 res.status = 200 res.reason = "OK" res:write("[]") res:setHeader("Content-Type", "application/json") return false end):onGet("/", function(req, res) res.status = 200 res.reason = "OK" res:write("/info\n/command\n/message") res:setHeader("Content-Type", "text/html") return false end):listen("127.0.0.1", 56803)
有关的日志/输出
No response
插件列表