Commit 5a7e4d888e6b2f922bad3592f8dcf852a545e572
1 parent
92ef9591
自定义维护公告
Showing
2 changed files
with
26 additions
and
6 deletions
Show diff stats
src/ProtocolCode.lua
@@ -6,6 +6,7 @@ actionCodes = { | @@ -6,6 +6,7 @@ actionCodes = { | ||
6 | Sys_innerErrorMsg = 4, | 6 | Sys_innerErrorMsg = 4, |
7 | Sys_commonNotice = 5, | 7 | Sys_commonNotice = 5, |
8 | Sys_maintainNotice = 6, | 8 | Sys_maintainNotice = 6, |
9 | + Sys_customNotice = 7, | ||
9 | 10 | ||
10 | Gm_clientRequest = 20, | 11 | Gm_clientRequest = 20, |
11 | Gm_receiveResponse = 21, | 12 | Gm_receiveResponse = 21, |
src/actions/HttpAction.lua
@@ -148,13 +148,32 @@ function _M.gm_action(query) | @@ -148,13 +148,32 @@ function _M.gm_action(query) | ||
148 | end | 148 | end |
149 | 149 | ||
150 | function _M.broadcast(query) | 150 | function _M.broadcast(query) |
151 | - local bin = MsgPack.pack({body = query.content}) | ||
152 | - local codes = { | ||
153 | - ["common"] = actionCodes.Sys_commonNotice, | ||
154 | - ["maintain"] = actionCodes.Sys_maintainNotice, | 151 | + local msg = {} |
152 | + local handle = { | ||
153 | + ["common"] = { | ||
154 | + code = actionCodes.Sys_commonNotice, | ||
155 | + exec = function() | ||
156 | + msg["body"] = query.content | ||
157 | + end | ||
158 | + }, | ||
159 | + ["maintain"] = { | ||
160 | + code = actionCodes.Sys_maintainNotice, | ||
161 | + exec = function() | ||
162 | + msg["body"] = query.content | ||
163 | + end | ||
164 | + }, | ||
165 | + ["custom"] = { | ||
166 | + code = actionCodes.Sys_customNotice, | ||
167 | + exec = function() | ||
168 | + msg["title"] = query.title | ||
169 | + msg["body"] = query.content | ||
170 | + msg["logout"] = query.logout | ||
171 | + end | ||
172 | + } | ||
155 | } | 173 | } |
156 | - if not codes[query.cmd] then return "错误" end | ||
157 | - mcast_util.pub_world(codes[query.cmd], bin) | 174 | + if not handle[query.cmd] then return "错误" end |
175 | + handle[query.cmd].exec() | ||
176 | + mcast_util.pub_world(handle[query.cmd].code, MsgPack.pack(msg)) | ||
158 | return "广播成功" | 177 | return "广播成功" |
159 | end | 178 | end |
160 | 179 |