sproto dispatch support ud

This commit is contained in:
Cloud Wu
2016-01-05 16:06:20 +08:00
parent 7f0e4eac8a
commit 64c2cb1b51

View File

@@ -197,6 +197,7 @@ function host:dispatch(...)
local bin = core.unpack(...)
header_tmp.type = nil
header_tmp.session = nil
header_tmp.ud = nil
local header, size = core.decode(self.__package, bin, header_tmp)
local content = bin:sub(size + 1)
if header.type then
@@ -207,9 +208,9 @@ function host:dispatch(...)
result = core.decode(proto.request, content)
end
if header_tmp.session then
return "REQUEST", proto.name, result, gen_response(self, proto.response, header_tmp.session)
return "REQUEST", proto.name, result, gen_response(self, proto.response, header_tmp.session), header.ud
else
return "REQUEST", proto.name, result
return "REQUEST", proto.name, result, nil, header.ud
end
else
-- response
@@ -217,10 +218,10 @@ function host:dispatch(...)
local response = assert(self.__session[session], "Unknown session")
self.__session[session] = nil
if response == true then
return "RESPONSE", session
return "RESPONSE", session, nil, header.ud
else
local result = core.decode(response, content)
return "RESPONSE", session, result
return "RESPONSE", session, result, header.ud
end
end
end