improve unregister protocol error report

This commit is contained in:
Cloud Wu
2015-07-23 18:23:47 +08:00
parent 39f9a96b6c
commit b2d8237363
2 changed files with 20 additions and 4 deletions

View File

@@ -415,9 +415,13 @@ function skynet.wakeup(co)
end
function skynet.dispatch(typename, func)
local p = assert(proto[typename],tostring(typename))
assert(p.dispatch == nil, tostring(typename))
local p = proto[typename]
if func then
assert(p and (p.dispatch == nil), tostring(typename))
p.dispatch = func
else
return p and p.dispatch
end
end
local function unknown_request(session, address, msg, sz, prototype)
@@ -466,7 +470,15 @@ local function raw_dispatch_message(prototype, msg, sz, session, source, ...)
suspend(co, coroutine.resume(co, true, msg, sz))
end
else
local p = assert(proto[prototype], prototype)
local p = proto[prototype]
if p == nil then
if session ~= 0 then
c.send(source, skynet.PTYPE_ERROR, session, "")
else
unknown_request(session, source, msg, sz, prototype)
end
return
end
local f = p.dispatch
if f then
local ref = watching_service[source]

View File

@@ -63,6 +63,10 @@ function dbgcmd.REMOTEDEBUG(...)
remotedebug.start(export, ...)
end
function dbgcmd.SUPPORT(pname)
return skynet.ret(skynet.pack(skynet.dispatch(pname) ~= nil))
end
local function _debug_dispatch(session, address, cmd, ...)
local f = dbgcmd[cmd]
assert(f, cmd)