From 974323b5885b85818c09afeda73e1832a3779d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 20 Nov 2019 14:35:36 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=9D=A5=E8=87=AA=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E7=9A=84=20notify=20=E4=BC=9A=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=9B=9E=E5=A4=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/proto/proto.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'server-beta') diff --git a/server-beta/src/proto/proto.lua b/server-beta/src/proto/proto.lua index e12631aa..f04653d5 100644 --- a/server-beta/src/proto/proto.lua +++ b/server-beta/src/proto/proto.lua @@ -25,6 +25,10 @@ function m.on(method, callback) end function m.response(id, res) + if id == nil then + log.error('Response id is nil!', util.dump(res)) + return + end -- res 可能是nil,为了转成json时保留nil,使用 container 容器 local data = util.container() data.id = id @@ -35,6 +39,10 @@ function m.response(id, res) end function m.responseErr(id, code, message) + if id == nil then + log.error('Response id is nil!', util.dump(message)) + return + end local buf = jsonrpc.encode { id = id, error = { @@ -88,6 +96,9 @@ function m.doMethod(proto) if passed > 0.2 then log.debug(('Method [%s] takes [%.3f]sec.'):format(method, passed)) end + if not proto.id then + return + end if ok then m.response(proto.id, res) else -- cgit v1.2.3