mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 15:10:03 +00:00
reupdate v1.0.7
This commit is contained in:
parent
563af05c62
commit
ae1754d616
2 changed files with 21 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
--!optimize 2
|
||||||
local ClientProcess = {}
|
local ClientProcess = {}
|
||||||
|
|
||||||
local RunService = game:GetService("RunService")
|
local RunService = game:GetService("RunService")
|
||||||
|
@ -10,6 +11,7 @@ local Event = require(script.Parent.Parent.Event)
|
||||||
local Spawn = require(Util.Spawn)
|
local Spawn = require(Util.Spawn)
|
||||||
local Key = require(Util.Key)
|
local Key = require(Util.Key)
|
||||||
local RateLimit = require(Util.RateLimit)
|
local RateLimit = require(Util.RateLimit)
|
||||||
|
local Buffer = require(Util.Buffer)
|
||||||
|
|
||||||
local clientRatelimit: Type.StoredRatelimit = {}
|
local clientRatelimit: Type.StoredRatelimit = {}
|
||||||
local clientQueue: Type.QueueMap = {}
|
local clientQueue: Type.QueueMap = {}
|
||||||
|
@ -99,7 +101,7 @@ function ClientProcess.start()
|
||||||
for Identifier: string, data: any in unreliableClientQueue do
|
for Identifier: string, data: any in unreliableClientQueue do
|
||||||
if #data > 0 then
|
if #data > 0 then
|
||||||
if clientRatelimit[Identifier](#data) then
|
if clientRatelimit[Identifier](#data) then
|
||||||
UnreliableEvent:FireServer(Identifier, data)
|
UnreliableEvent:FireServer(Buffer.revert(Identifier), data)
|
||||||
end
|
end
|
||||||
table.clear(data)
|
table.clear(data)
|
||||||
end
|
end
|
||||||
|
@ -107,7 +109,7 @@ function ClientProcess.start()
|
||||||
for Identifier: string, data: any in clientQueue do
|
for Identifier: string, data: any in clientQueue do
|
||||||
if #data > 0 then
|
if #data > 0 then
|
||||||
if clientRatelimit[Identifier](#data) then
|
if clientRatelimit[Identifier](#data) then
|
||||||
ReliableEvent:FireServer(Identifier, data)
|
ReliableEvent:FireServer(Buffer.revert(Identifier), data)
|
||||||
end
|
end
|
||||||
table.clear(data)
|
table.clear(data)
|
||||||
end
|
end
|
||||||
|
@ -170,17 +172,18 @@ function ClientProcess.start()
|
||||||
end
|
end
|
||||||
for Identifier: string, requestsData in queueOutRequest[1] do
|
for Identifier: string, requestsData in queueOutRequest[1] do
|
||||||
if #requestsData == 0 then continue end
|
if #requestsData == 0 then continue end
|
||||||
RequestEvent:FireServer(Identifier, "\1", requestsData)
|
RequestEvent:FireServer(Buffer.revert(Identifier), "\1", requestsData)
|
||||||
table.clear(queueOutRequest[1][Identifier])
|
table.clear(queueOutRequest[1][Identifier])
|
||||||
end
|
end
|
||||||
for Identifier: string, requestsData in queueOutRequest[2] do
|
for Identifier: string, requestsData in queueOutRequest[2] do
|
||||||
if #requestsData == 0 then continue end
|
if #requestsData == 0 then continue end
|
||||||
RequestEvent:FireServer(Identifier, "\0", requestsData)
|
RequestEvent:FireServer(Buffer.revert(Identifier), "\0", requestsData)
|
||||||
table.clear(queueOutRequest[2][Identifier])
|
table.clear(queueOutRequest[2][Identifier])
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
local function onClientNetworkReceive(Identifier: string, data: any)
|
local function onClientNetworkReceive(Identifier: any, data: any)
|
||||||
if not Identifier or not data then return end
|
if not Identifier or not data then return end
|
||||||
|
Identifier = Buffer.convert(Identifier)
|
||||||
if not queueIn[Identifier] then
|
if not queueIn[Identifier] then
|
||||||
queueIn[Identifier] = {}
|
queueIn[Identifier] = {}
|
||||||
end
|
end
|
||||||
|
@ -195,8 +198,9 @@ function ClientProcess.start()
|
||||||
end
|
end
|
||||||
ReliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
ReliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
||||||
UnreliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
UnreliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
||||||
RequestEvent.OnClientEvent:Connect(function(Identifier: string, action: string, returnDatas)
|
RequestEvent.OnClientEvent:Connect(function(Identifier: any, action: string, returnDatas)
|
||||||
if not Identifier or not returnDatas then return end
|
if not Identifier or not returnDatas then return end
|
||||||
|
Identifier = Buffer.convert(Identifier)
|
||||||
if action == "\1" then
|
if action == "\1" then
|
||||||
table.insert(queueInRequest[1][Identifier], returnDatas)
|
table.insert(queueInRequest[1][Identifier], returnDatas)
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
--!optimize 2
|
||||||
local ServerProcess = {}
|
local ServerProcess = {}
|
||||||
|
|
||||||
local RunService = game:GetService("RunService")
|
local RunService = game:GetService("RunService")
|
||||||
|
@ -11,6 +12,7 @@ local Event = require(script.Parent.Parent.Event)
|
||||||
local Spawn = require(Util.Spawn)
|
local Spawn = require(Util.Spawn)
|
||||||
local Key = require(Util.Key)
|
local Key = require(Util.Key)
|
||||||
local RateLimit = require(Util.RateLimit)
|
local RateLimit = require(Util.RateLimit)
|
||||||
|
local Buffer = require(Util.Buffer)
|
||||||
|
|
||||||
local serverQueue: Type.QueueMap = {}
|
local serverQueue: Type.QueueMap = {}
|
||||||
local unreliableServerQueue: Type.QueueMap = {}
|
local unreliableServerQueue: Type.QueueMap = {}
|
||||||
|
@ -130,6 +132,7 @@ function ServerProcess.add(Identifier: string, originId: string, ratelimit: Type
|
||||||
end
|
end
|
||||||
|
|
||||||
function ServerProcess.addCallback(Identifier: string, key: string, callback)
|
function ServerProcess.addCallback(Identifier: string, key: string, callback)
|
||||||
|
print(serverCallback, Identifier)
|
||||||
serverCallback[Identifier][key] = callback
|
serverCallback[Identifier][key] = callback
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,7 +145,7 @@ function ServerProcess.start()
|
||||||
for Identifier: string, players in unreliableServerQueue do
|
for Identifier: string, players in unreliableServerQueue do
|
||||||
for player: Player, data: any in players do
|
for player: Player, data: any in players do
|
||||||
if #data == 0 then continue end
|
if #data == 0 then continue end
|
||||||
UnreliableEvent:FireClient(player, Identifier, data)
|
UnreliableEvent:FireClient(player, Buffer.revert(Identifier), data)
|
||||||
table.clear(data)
|
table.clear(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -150,7 +153,7 @@ function ServerProcess.start()
|
||||||
if not queueOut[player] then continue end
|
if not queueOut[player] then continue end
|
||||||
for Identifier: string, data: any in queueOut[player] do
|
for Identifier: string, data: any in queueOut[player] do
|
||||||
if #data == 0 then continue end
|
if #data == 0 then continue end
|
||||||
ReliableEvent:FireClient(player, Identifier, data)
|
ReliableEvent:FireClient(player, Buffer.revert(Identifier), data)
|
||||||
table.clear(data)
|
table.clear(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -210,20 +213,21 @@ function ServerProcess.start()
|
||||||
end
|
end
|
||||||
for player: Player, requestsData: any in queueOutRequest[1][Identifier] do
|
for player: Player, requestsData: any in queueOutRequest[1][Identifier] do
|
||||||
if #requestsData == 0 then continue end
|
if #requestsData == 0 then continue end
|
||||||
RequestEvent:FireClient(player, Identifier, "\1", requestsData)
|
RequestEvent:FireClient(player, Buffer.revert(Identifier), "\1", requestsData)
|
||||||
table.clear(requestsData)
|
table.clear(requestsData)
|
||||||
end
|
end
|
||||||
for player: Player, toReturnDatas: any in queueOutRequest[2][Identifier] do
|
for player: Player, toReturnDatas: any in queueOutRequest[2][Identifier] do
|
||||||
if #toReturnDatas == 0 then continue end
|
if #toReturnDatas == 0 then continue end
|
||||||
RequestEvent:FireClient(player, Identifier, "\0", toReturnDatas)
|
RequestEvent:FireClient(player, Buffer.revert(Identifier), "\0", toReturnDatas)
|
||||||
table.clear(toReturnDatas)
|
table.clear(toReturnDatas)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
local function onServerNetworkReceive(player: Player, Identifier: string, data: any)
|
local function onServerNetworkReceive(player: Player, Identifier: any, data: any)
|
||||||
if not Identifier or not data then return end
|
if not Identifier or not data then return end
|
||||||
|
Identifier = Buffer.convert(Identifier)
|
||||||
if not serverQueue[Identifier] then
|
if not serverQueue[Identifier] then
|
||||||
serverQueue[Identifier] = {}
|
serverQueue[Identifier] = {}
|
||||||
end
|
end
|
||||||
|
@ -237,8 +241,9 @@ function ServerProcess.start()
|
||||||
end
|
end
|
||||||
ReliableEvent.OnServerEvent:Connect(onServerNetworkReceive)
|
ReliableEvent.OnServerEvent:Connect(onServerNetworkReceive)
|
||||||
UnreliableEvent.OnServerEvent:Connect(onServerNetworkReceive)
|
UnreliableEvent.OnServerEvent:Connect(onServerNetworkReceive)
|
||||||
RequestEvent.OnServerEvent:Connect(function(player: Player, Identifier: string, action: string, data: any)
|
RequestEvent.OnServerEvent:Connect(function(player: Player, Identifier: any, action: string, data: any)
|
||||||
if not Identifier or not data then return end
|
if not Identifier or not data then return end
|
||||||
|
Identifier = Buffer.convert(Identifier)
|
||||||
if not queueInRequest[1][Identifier][player] then
|
if not queueInRequest[1][Identifier][player] then
|
||||||
queueInRequest[1][Identifier][player] = {}
|
queueInRequest[1][Identifier][player] = {}
|
||||||
queueInRequest[2][Identifier][player] = {}
|
queueInRequest[2][Identifier][player] = {}
|
||||||
|
|
Loading…
Reference in a new issue