local pb = require "pb"

local ProtoMsgDispatch =
{
	msgCallbacks = {}
}

ProtoMsgDispatch.ERROR_CODE =
{
	SUCCESS = 0,
}

function ProtoMsgDispatch:getMsgIdByMsgName(msgName)
	local msgId = ProtoMsgType.FromMsgToId[msgName]
	return msgId
end

function ProtoMsgDispatch:getRspMsgByMsgName(msgName)
	local str = string.gsub(msgName, "Req", "Rsp")
	return str
end

function ProtoMsgDispatch:getReqMsgByMsgName(msgName)
	local str = string.gsub(msgName, "Rsp", "Req")
	return str
end

function ProtoMsgDispatch:getMsgFullNameByMsgName(msgName)
	return "cspb." .. msgName
end

function ProtoMsgDispatch:getReqMsgNameByMsgId(msgId)
	local reqName = ProtoMsgType.FromMsgId[msgId]
	return reqName
end

function ProtoMsgDispatch:getErrCodeEnum(errCode)
	local code = pb.enum("cspb.ErrCode", errCode)
	return code
end

function ProtoMsgDispatch:getKickOutReasonEnum(enum)
	local code = pb.enum("cspb.KickOutReason", enum)
	return code
end

-- function ProtoMsgDispatch:getRspMsgNameByGrpCmd(grp, cmd)
-- 	local rspName = ProtoMsgType.FromMsgId[grp * 1000 + cmd]
-- 	if rspName == nil then
-- 		return
-- 	end
-- 	return 'rsp' .. rspName
-- end

-- function ProtoMsgDispatch:getReqMsgName(id)
-- 	local reqName = ProtoMsgType.FromMsgId[id]
-- 	if reqName == nil then
-- 		return
-- 	end
-- 	return 'req' .. reqName
-- end

-- function ProtoMsgDispatch:getRspMsgName(id)
-- 	local rspName = ProtoMsgType.FromMsgId[id]
-- 	if rspName == nil then
-- 		return
-- 	end
-- 	return 'rsp' .. rspName
-- end

-- function ProtoMsgDispatch:dispatch(msgName, data)
-- 	if self.msgCallbacks[msgName] then
-- 		for module, callback in pairs(self.msgCallbacks[msgName]) do
-- 			callback(module, data)
-- 		end
-- 	end
-- end

-- function ProtoMsgDispatch:rspHeroBuy(data)
-- 	HeroMgr:onReceiveHeroListExpaned(data)
-- end

return ProtoMsgDispatch