This commit is contained in:
EternityDev 2024-04-09 15:49:06 +07:00
parent 739e13537d
commit 8fd9573b8a
3 changed files with 66 additions and 28 deletions

View file

@ -78,18 +78,38 @@ end
function ClientProcess.add(Identifier: any, originId: string) function ClientProcess.add(Identifier: any, originId: string)
if not clientQueue[Identifier] then if not clientQueue[Identifier] then
if not clientRatelimit[Identifier] then
clientRatelimit[Identifier] = RateLimit.create(originId) clientRatelimit[Identifier] = RateLimit.create(originId)
end
if not clientQueue[Identifier] then
clientQueue[Identifier] = {} clientQueue[Identifier] = {}
end
if not unreliableClientQueue[Identifier] then
unreliableClientQueue[Identifier] = {} unreliableClientQueue[Identifier] = {}
end
if not clientRequestQueue[Identifier] then
clientRequestQueue[Identifier] = {} clientRequestQueue[Identifier] = {}
end
if not clientCallback[Identifier] then
clientCallback[Identifier] = {} clientCallback[Identifier] = {}
end
if not queueOutRequest[1][Identifier] then
queueOutRequest[1][Identifier] = {} queueOutRequest[1][Identifier] = {}
end
if not queueOutRequest[2][Identifier] then
queueOutRequest[2][Identifier] = {} queueOutRequest[2][Identifier] = {}
end
if not queueInRequest[1][Identifier] then
queueInRequest[1][Identifier] = {} queueInRequest[1][Identifier] = {}
end
if not queueInRequest[2][Identifier] then
queueInRequest[2][Identifier] = {} queueInRequest[2][Identifier] = {}
end
if not queueIn[Identifier] then
queueIn[Identifier] = {} queueIn[Identifier] = {}
end end
end
end end
function ClientProcess.logger(Identifier: string, store: boolean, log: boolean) function ClientProcess.logger(Identifier: string, store: boolean, log: boolean)

View file

@ -119,16 +119,34 @@ end
function ServerProcess.add(Identifier: string, originId: string, ratelimit: Type.rateLimitArg) function ServerProcess.add(Identifier: string, originId: string, ratelimit: Type.rateLimitArg)
if not serverQueue[Identifier] then if not serverQueue[Identifier] then
RateLimit.create(originId, ratelimit.maxEntrance or 200, ratelimit.interval or 2) RateLimit.create(originId, ratelimit.maxEntrance or 200, ratelimit.interval or 2)
if not serverQueue[Identifier] then
serverQueue[Identifier] = {} serverQueue[Identifier] = {}
end
if not unreliableServerQueue[Identifier] then
unreliableServerQueue[Identifier] = {} unreliableServerQueue[Identifier] = {}
end
if not serverCallback[Identifier] then
serverCallback[Identifier] = {} serverCallback[Identifier] = {}
end
if not serverRequestQueue[Identifier] then
serverRequestQueue[Identifier] = {} serverRequestQueue[Identifier] = {}
end
if not queueIn[Identifier] then
queueIn[Identifier] = {} queueIn[Identifier] = {}
end
if not queueInRequest[1][Identifier] then
queueInRequest[1][Identifier] = {} queueInRequest[1][Identifier] = {}
end
if not queueInRequest[2][Identifier] then
queueInRequest[2][Identifier] = {} queueInRequest[2][Identifier] = {}
end
if not queueOutRequest[1][Identifier] then
queueOutRequest[1][Identifier] = {} queueOutRequest[1][Identifier] = {}
end
if not queueOutRequest[2][Identifier] then
queueOutRequest[2][Identifier] = {} queueOutRequest[2][Identifier] = {}
end
for _, player: Player in ipairs(Players:GetPlayers()) do for _, player: Player in ipairs(Players:GetPlayers()) do
task.spawn(initializeEachPlayer, player) task.spawn(initializeEachPlayer, player)

View file

@ -59,55 +59,55 @@ end
function DedicatedBuffer.wi8(self: any, val: number) function DedicatedBuffer.wi8(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(1) self:alloc(1)
writei8(self.buffer, self.point, val) writei8(self.buffer, self.point, val)
end end
function DedicatedBuffer.wi16(self: any, val: number) function DedicatedBuffer.wi16(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(2) self:alloc(2)
writei16(self.buffer, self.point, val) writei16(self.buffer, self.point, val)
end end
function DedicatedBuffer.wi32(self: any, val: number) function DedicatedBuffer.wi32(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(4) self:alloc(4)
writei32(self.buffer, self.point, val) writei32(self.buffer, self.point, val)
end end
function DedicatedBuffer.wu8(self: any, val: number) function DedicatedBuffer.wu8(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(1) self:alloc(1)
writeu8(self.buffer, self.point, val) writeu8(self.buffer, self.point, val)
end end
function DedicatedBuffer.wu16(self: any, val: number) function DedicatedBuffer.wu16(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(2) self:alloc(2)
writeu16(self.buffer, self.point, val) writeu16(self.buffer, self.point, val)
end end
function DedicatedBuffer.wu32(self: any, val: number) function DedicatedBuffer.wu32(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(4) self:alloc(4)
writeu32(self.buffer, self.point, val) writeu32(self.buffer, self.point, val)
end end
function DedicatedBuffer.wf32(self: any, val: number) function DedicatedBuffer.wf32(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(4) self:alloc(4)
writef32(self.buffer, self.point, val) writef32(self.buffer, self.point, val)
end end
function DedicatedBuffer.wf64(self: any, val: number) function DedicatedBuffer.wf64(self: any, val: number)
if not val then return end if not val then return end
DedicatedBuffer:alloc(8) self:alloc(8)
writef64(self.buffer, self.point, val) writef64(self.buffer, self.point, val)
end end
function DedicatedBuffer.wstring(self: any, val: string) function DedicatedBuffer.wstring(self: any, val: string)
if not val then return end if not val then return end
DedicatedBuffer:alloc(#val) self:alloc(#val)
writestring(self.buffer, self.point, val) writestring(self.buffer, self.point, val)
end end