del[lua]: remove useless code

This commit is contained in:
godotg
2024-05-23 15:34:47 +08:00
parent d676fd0dff
commit 605ec80de8
5 changed files with 0 additions and 82 deletions
@@ -1,11 +0,0 @@
function Protocols.{}:protocolId()
return {}
end
function Protocols.{}:protocolName()
return "{}"
end
function Protocols.{}:__tostring()
return table.serializeTableToJson(self)
end
@@ -1,41 +0,0 @@
local protocols = {}
local ProtocolManager = {}
-- table扩展方法,map的大小
function table.mapSize(map)
local size = 0
for _,_ in pairs(map) do
size = size + 1
end
return size
end
function ProtocolManager.getProtocol(protocolId)
local protocol = protocols[protocolId]
if protocol == nil then
error("[protocolId:" + protocolId + "]协议不存在")
end
return protocol
end
function ProtocolManager.write(buffer, packet)
local protocolId = packet:protocolId()
-- 写入协议号
buffer:writeShort(protocolId)
-- 写入包体
ProtocolManager.getProtocol(protocolId):write(buffer, packet)
end
function ProtocolManager.read(buffer)
local protocolId = buffer:readShort()
return ProtocolManager.getProtocol(protocolId):read(buffer)
end
function initProtocol()
{}
{}
end
ProtocolManager.initProtocol = initProtocol
return ProtocolManager
@@ -1,13 +0,0 @@
function Protocols.{}:read(buffer)
local length = buffer:readInt()
if length == 0 then
return nil
end
local beforeReadIndex = buffer:getReadOffset()
local packet = Protocols.{}:new()
{}
if length > 0 then
buffer:setReadOffset(beforeReadIndex + length)
end
return packet
end
@@ -1,10 +0,0 @@
{}
local {} = {}
function {}:new()
local obj = {
{}
}
setmetatable(obj, self)
self.__index = self
return obj
end
@@ -1,7 +0,0 @@
function Protocols.{}:write(buffer, packet)
if packet == nil then
buffer:writeInt(0)
return
end
{}
end