local skynet = require "skynet" local sharedata = require "skynet.sharedata" local codecache = require "skynet.codecache" -- 清空缓存用 local _M = {} -- 清空缓存 function _M.clearcache(query, body) skynet.error(string.format("clearcache time: %s", skynet.timex())) codecache.clear() return 'success' end --重新加载 需要修改的csvdb --[=[ eg: body = """ csvdb["itemCsv"][1]["name"] = "测试一下" """ ]=] function _M.reload_csvdata(query, body) if not body or body == "" then return end local ok = pcall(load, body) if not ok then return end skynet.error(string.format("reload_csvdata time: %s, code: %s", skynet.timex(), body)) local status = skynet.call('CSVDATA', "lua", "reload", body) if status == "ok" then return 'success' end end -- 热更新代码 -- 针对 agent 执行发送过来的代码 -- 代码要规范~ --[=[ eg: 1. *Action body = """ _hotfixActions = _hotfixActions or {} _hotfixActions["Gm.clientRequest"] = function(agent, data) bin = MsgPack.pack({ cmd = "testtest" }) SendPacket(actionCodes.Gm_receiveResponse, bin) end """ 2. 修改 global 方法 和 变量 直接覆盖 body = """ function a() print(123) end globalCsv["asdasd"] = 12 HEHE = 123 """ 3. 修改 role 方法(待定) body = """ """ ]=] function _M.hotfix(query, body) if not body or body == "" then return end local ok = pcall(load, body) if not ok then return end skynet.error(string.format("hotfix time: %s, code: %s", skynet.timex(), body)) pcall(skynet.call, 'WATCHDOG', "lua", "hotfix", body) return 'success' end return _M