diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index c19a44b..f4e2f08 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -6,6 +6,7 @@ actionCodes = { Sys_innerErrorMsg = 4, Sys_commonNotice = 5, Sys_maintainNotice = 6, + Sys_customNotice = 7, Gm_clientRequest = 20, Gm_receiveResponse = 21, diff --git a/src/actions/HttpAction.lua b/src/actions/HttpAction.lua index 6e3984a..d475688 100644 --- a/src/actions/HttpAction.lua +++ b/src/actions/HttpAction.lua @@ -148,13 +148,32 @@ function _M.gm_action(query) end function _M.broadcast(query) - local bin = MsgPack.pack({body = query.content}) - local codes = { - ["common"] = actionCodes.Sys_commonNotice, - ["maintain"] = actionCodes.Sys_maintainNotice, + local msg = {} + local handle = { + ["common"] = { + code = actionCodes.Sys_commonNotice, + exec = function() + msg["body"] = query.content + end + }, + ["maintain"] = { + code = actionCodes.Sys_maintainNotice, + exec = function() + msg["body"] = query.content + end + }, + ["custom"] = { + code = actionCodes.Sys_customNotice, + exec = function() + msg["title"] = query.title + msg["body"] = query.content + msg["logout"] = query.logout + end + } } - if not codes[query.cmd] then return "错误" end - mcast_util.pub_world(codes[query.cmd], bin) + if not handle[query.cmd] then return "错误" end + handle[query.cmd].exec() + mcast_util.pub_world(handle[query.cmd].code, MsgPack.pack(msg)) return "广播成功" end -- libgit2 0.21.2