HttpAction.lua
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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