mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 15:10:03 +00:00
v1.0.10
This commit is contained in:
parent
acb08a385c
commit
839a7af667
7 changed files with 63 additions and 35 deletions
|
@ -1,4 +1,6 @@
|
||||||
--!strict
|
--!strict
|
||||||
|
--!native
|
||||||
|
--!optimize 2
|
||||||
local Logger = {}
|
local Logger = {}
|
||||||
local Logs: {
|
local Logs: {
|
||||||
[string]: {
|
[string]: {
|
||||||
|
|
|
@ -70,6 +70,9 @@ function ClientProcess.insertQueue(Identifier: string, reliable: boolean, ...: a
|
||||||
end
|
end
|
||||||
|
|
||||||
function ClientProcess.insertRequest(Identifier: string, timeout: number, ...: any)
|
function ClientProcess.insertRequest(Identifier: string, timeout: number, ...: any)
|
||||||
|
if not clientRequestQueue[Identifier] then
|
||||||
|
clientRequestQueue[Identifier] = {}
|
||||||
|
end
|
||||||
local yieldThread: thread, start = coroutine.running(), os.clock()
|
local yieldThread: thread, start = coroutine.running(), os.clock()
|
||||||
local cancel = task.delay(timeout, function()
|
local cancel = task.delay(timeout, function()
|
||||||
task.spawn(yieldThread, nil)
|
task.spawn(yieldThread, nil)
|
||||||
|
@ -168,15 +171,15 @@ function ClientProcess.start()
|
||||||
end
|
end
|
||||||
clientQueue[Identifier] = nil
|
clientQueue[Identifier] = nil
|
||||||
end
|
end
|
||||||
if #clientRequestQueue[Identifier] > 0 then
|
if clientRequestQueue[Identifier] then
|
||||||
for _, requestData in clientRequestQueue[Identifier] do
|
for _, requestData in clientRequestQueue[Identifier] do
|
||||||
if not requestData[3] then continue end
|
if not requestData[3] then continue end
|
||||||
if not queueOutRequest[1][Identifier] then
|
if not queueOutRequest[1][Identifier] then
|
||||||
queueOutRequest[1][Identifier] = {}
|
queueOutRequest[1][Identifier] = {}
|
||||||
end
|
end
|
||||||
table.insert(queueOutRequest[1][Identifier], { requestData[1], requestData[3] })
|
table.insert(queueOutRequest[1][Identifier], { requestData[1], requestData[3] })
|
||||||
table.remove(requestData, #requestData)
|
|
||||||
end
|
end
|
||||||
|
clientRequestQueue[Identifier] = nil
|
||||||
end
|
end
|
||||||
if callback then
|
if callback then
|
||||||
if incoming_cache[Identifier] then
|
if incoming_cache[Identifier] then
|
||||||
|
@ -187,8 +190,8 @@ function ClientProcess.start()
|
||||||
Spawn(fn, table.unpack(packet[i] or {}))
|
Spawn(fn, table.unpack(packet[i] or {}))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
incoming_cache[Identifier] = nil
|
|
||||||
end
|
end
|
||||||
|
incoming_cache[Identifier] = nil
|
||||||
end
|
end
|
||||||
if queueIn[Identifier] then
|
if queueIn[Identifier] then
|
||||||
for _, packedDatas: any in queueIn[Identifier] do
|
for _, packedDatas: any in queueIn[Identifier] do
|
||||||
|
@ -221,6 +224,7 @@ function ClientProcess.start()
|
||||||
queueInRequest[1][Identifier] = nil
|
queueInRequest[1][Identifier] = nil
|
||||||
end
|
end
|
||||||
if queueInRequest[2][Identifier] then
|
if queueInRequest[2][Identifier] then
|
||||||
|
if clientRequestQueue[Identifier] then
|
||||||
for _, packetDatas: any in queueInRequest[2][Identifier] do
|
for _, packetDatas: any in queueInRequest[2][Identifier] do
|
||||||
for _, packetData in packetDatas do
|
for _, packetData in packetDatas do
|
||||||
if #packetData == 1 then continue end
|
if #packetData == 1 then continue end
|
||||||
|
@ -235,6 +239,7 @@ function ClientProcess.start()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
queueInRequest[2][Identifier] = nil
|
queueInRequest[2][Identifier] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -262,17 +267,20 @@ function ClientProcess.start()
|
||||||
if not queueIn[Identifier] then
|
if not queueIn[Identifier] then
|
||||||
queueIn[Identifier] = {}
|
queueIn[Identifier] = {}
|
||||||
end
|
end
|
||||||
if logger[Identifier] then
|
|
||||||
task.defer(Logger.write, Identifier, `state: in -> net -> {#data} data.`)
|
|
||||||
end
|
|
||||||
if not clientCallback[Identifier] then
|
if not clientCallback[Identifier] then
|
||||||
if not incoming_cache[Identifier] then
|
if not incoming_cache[Identifier] then
|
||||||
incoming_cache[Identifier] = {}
|
incoming_cache[Identifier] = {}
|
||||||
end
|
end
|
||||||
table.insert(incoming_cache[Identifier], data)
|
table.insert(incoming_cache[Identifier], data)
|
||||||
|
if logger[Identifier] then
|
||||||
|
task.defer(Logger.write, Identifier, `state: cache -> net -> {#data} data.`)
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
table.insert(queueIn[Identifier], data)
|
table.insert(queueIn[Identifier], data)
|
||||||
|
if logger[Identifier] then
|
||||||
|
task.defer(Logger.write, Identifier, `state: in -> net -> {#data} data.`)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
ReliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
ReliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
||||||
UnreliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
UnreliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
--!strict
|
--!strict
|
||||||
|
--!native
|
||||||
|
--!optimize 2
|
||||||
local RunService = game:GetService("RunService")
|
local RunService = game:GetService("RunService")
|
||||||
local Type = require(script.Parent.Type)
|
local Type = require(script.Parent.Type)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
--!strict
|
--!strict
|
||||||
|
--!native
|
||||||
|
--!optimize 2
|
||||||
local Logger = {}
|
local Logger = {}
|
||||||
local Logs: {
|
local Logs: {
|
||||||
[string]: {
|
[string]: {
|
||||||
|
|
|
@ -109,6 +109,9 @@ function ServerProcess.insertRequest(Identifier: string, timeout: number, player
|
||||||
if not serverQueue[Identifier][player] then
|
if not serverQueue[Identifier][player] then
|
||||||
serverQueue[Identifier][player] = {}
|
serverQueue[Identifier][player] = {}
|
||||||
end
|
end
|
||||||
|
if not serverRequestQueue[Identifier] then
|
||||||
|
serverRequestQueue[Identifier] = {}
|
||||||
|
end
|
||||||
local yieldThread: thread, start = coroutine.running(), os.clock()
|
local yieldThread: thread, start = coroutine.running(), os.clock()
|
||||||
local cancel = task.delay(timeout, function()
|
local cancel = task.delay(timeout, function()
|
||||||
task.spawn(yieldThread, nil)
|
task.spawn(yieldThread, nil)
|
||||||
|
@ -201,30 +204,45 @@ function ServerProcess.start()
|
||||||
end
|
end
|
||||||
|
|
||||||
for Identifier: string, contents: { [Player]: { any } } in serverQueue do
|
for Identifier: string, contents: { [Player]: { any } } in serverQueue do
|
||||||
|
|
||||||
|
for player: Player, requestsData: any in queueOutRequest[1][Identifier] do
|
||||||
|
if #requestsData > 0 then
|
||||||
|
RequestEvent:FireClient(player, Buffer.revert(Identifier), "\1", requestsData)
|
||||||
|
if logger[Identifier] then
|
||||||
|
task.defer(Logger.write, Identifier, `state: out -> request -> {#requestsData} data.`)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
queueOutRequest[1][Identifier][player] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
for player: Player, toReturnDatas: any in queueOutRequest[2][Identifier] do
|
||||||
|
if #toReturnDatas > 0 then
|
||||||
|
RequestEvent:FireClient(player, Buffer.revert(Identifier), "\0", toReturnDatas)
|
||||||
|
if logger[Identifier] then
|
||||||
|
task.defer(Logger.write, Identifier, `state: out -> return request -> {#toReturnDatas} data.`)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
queueOutRequest[2][Identifier][player] = nil
|
||||||
|
end
|
||||||
|
|
||||||
local callback = serverCallback[Identifier] or nil
|
local callback = serverCallback[Identifier] or nil
|
||||||
for player, content: any in contents do
|
for player, content: any in contents do
|
||||||
if #content > 0 and queueOut[player] then
|
if #content > 0 and queueOut[player] then
|
||||||
ReliableEvent:FireClient(player, Buffer.revert(Identifier), content)
|
ReliableEvent:FireClient(player, Buffer.revert(Identifier), content)
|
||||||
serverQueue[Identifier][player] = nil
|
|
||||||
end
|
end
|
||||||
if #serverRequestQueue[Identifier][player] > 0 then
|
serverQueue[Identifier][player] = nil
|
||||||
|
|
||||||
|
if serverRequestQueue[Identifier][player] then
|
||||||
for _, requestData in serverRequestQueue[Identifier][player] do
|
for _, requestData in serverRequestQueue[Identifier][player] do
|
||||||
if not requestData[3] then continue end
|
if not requestData[3] then continue end
|
||||||
if not queueOutRequest[1][Identifier][player] then
|
if not queueOutRequest[1][Identifier][player] then
|
||||||
queueOutRequest[1][Identifier][player] = {}
|
queueOutRequest[1][Identifier][player] = {}
|
||||||
end
|
end
|
||||||
table.insert(queueOutRequest[1][Identifier][player], { requestData[1], requestData[3] })
|
table.insert(queueOutRequest[1][Identifier][player], { requestData[1], requestData[3] })
|
||||||
|
end
|
||||||
serverRequestQueue[Identifier][player] = nil
|
serverRequestQueue[Identifier][player] = nil
|
||||||
end
|
end
|
||||||
end
|
|
||||||
for player: Player, requestsData: any in queueOutRequest[1][Identifier] do
|
|
||||||
if #requestsData == 0 then continue end
|
|
||||||
RequestEvent:FireClient(player, Buffer.revert(Identifier), "\1", requestsData)
|
|
||||||
if logger[Identifier] then
|
|
||||||
task.defer(Logger.write, Identifier, `state: out -> request -> {#requestsData} data.`)
|
|
||||||
end
|
|
||||||
queueOutRequest[1][Identifier][player] = nil
|
|
||||||
end
|
|
||||||
if callback then
|
if callback then
|
||||||
local requestIn1: any = queueInRequest[1][Identifier][player]
|
local requestIn1: any = queueInRequest[1][Identifier][player]
|
||||||
local requestIn2: any = queueInRequest[2][Identifier][player]
|
local requestIn2: any = queueInRequest[2][Identifier][player]
|
||||||
|
@ -283,14 +301,6 @@ function ServerProcess.start()
|
||||||
queueInRequest[2][Identifier][player] = nil
|
queueInRequest[2][Identifier][player] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for player: Player, toReturnDatas: any in queueOutRequest[2][Identifier] do
|
|
||||||
if #toReturnDatas == 0 then continue end
|
|
||||||
RequestEvent:FireClient(player, Buffer.revert(Identifier), "\0", toReturnDatas)
|
|
||||||
if logger[Identifier] then
|
|
||||||
task.defer(Logger.write, Identifier, `state: out -> return request -> {#toReturnDatas} data.`)
|
|
||||||
end
|
|
||||||
queueOutRequest[2][Identifier][player] = nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
--!strict
|
--!strict
|
||||||
|
--!native
|
||||||
|
--!optimize 2
|
||||||
local RateLimit = {}
|
local RateLimit = {}
|
||||||
|
|
||||||
local RunService = game:GetService("RunService")
|
local RunService = game:GetService("RunService")
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
--!strict
|
--!strict
|
||||||
|
--!native
|
||||||
|
--!optimize 2
|
||||||
local RunService = game:GetService("RunService")
|
local RunService = game:GetService("RunService")
|
||||||
local SerInt = 0
|
local SerInt = 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue