mirror of
				https://github.com/imezx/Warp.git
				synced 2025-11-03 19:49:16 +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
 | 
			
		||||
--!native
 | 
			
		||||
--!optimize 2
 | 
			
		||||
local Logger = {}
 | 
			
		||||
local Logs: {
 | 
			
		||||
	[string]: {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,6 +70,9 @@ function ClientProcess.insertQueue(Identifier: string, reliable: boolean, ...: a
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
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 cancel = task.delay(timeout, function()
 | 
			
		||||
		task.spawn(yieldThread, nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -168,15 +171,15 @@ function ClientProcess.start()
 | 
			
		|||
				end
 | 
			
		||||
				clientQueue[Identifier] = nil
 | 
			
		||||
			end
 | 
			
		||||
			if #clientRequestQueue[Identifier] > 0 then
 | 
			
		||||
			if clientRequestQueue[Identifier] then
 | 
			
		||||
				for _, requestData in clientRequestQueue[Identifier] do
 | 
			
		||||
					if not requestData[3] then continue end
 | 
			
		||||
					if not queueOutRequest[1][Identifier] then
 | 
			
		||||
						queueOutRequest[1][Identifier] = {}
 | 
			
		||||
					end
 | 
			
		||||
					table.insert(queueOutRequest[1][Identifier], { requestData[1], requestData[3] })
 | 
			
		||||
					table.remove(requestData, #requestData)
 | 
			
		||||
				end
 | 
			
		||||
				clientRequestQueue[Identifier] = nil
 | 
			
		||||
			end
 | 
			
		||||
			if callback then
 | 
			
		||||
				if incoming_cache[Identifier] then
 | 
			
		||||
| 
						 | 
				
			
			@ -187,8 +190,8 @@ function ClientProcess.start()
 | 
			
		|||
								Spawn(fn, table.unpack(packet[i] or {}))
 | 
			
		||||
							end
 | 
			
		||||
						end
 | 
			
		||||
						incoming_cache[Identifier] = nil
 | 
			
		||||
					end
 | 
			
		||||
					incoming_cache[Identifier] = nil
 | 
			
		||||
				end
 | 
			
		||||
				if queueIn[Identifier] then
 | 
			
		||||
					for _, packedDatas: any in queueIn[Identifier] do
 | 
			
		||||
| 
						 | 
				
			
			@ -221,16 +224,18 @@ function ClientProcess.start()
 | 
			
		|||
					queueInRequest[1][Identifier] = nil
 | 
			
		||||
				end
 | 
			
		||||
				if queueInRequest[2][Identifier] then
 | 
			
		||||
					for _, packetDatas: any in queueInRequest[2][Identifier] do
 | 
			
		||||
						for _, packetData in packetDatas do
 | 
			
		||||
							if #packetData == 1 then continue end
 | 
			
		||||
							for y=1,#clientRequestQueue[Identifier] do
 | 
			
		||||
								local clientRequest = clientRequestQueue[Identifier][y]
 | 
			
		||||
								if not clientRequest then continue end
 | 
			
		||||
								if clientRequest[1] == packetData[1] then
 | 
			
		||||
									Spawn(clientRequest[2], table.unpack(packetData[2]))
 | 
			
		||||
									table.remove(clientRequestQueue[Identifier], y)
 | 
			
		||||
									break
 | 
			
		||||
					if clientRequestQueue[Identifier] then
 | 
			
		||||
						for _, packetDatas: any in queueInRequest[2][Identifier] do
 | 
			
		||||
							for _, packetData in packetDatas do
 | 
			
		||||
								if #packetData == 1 then continue end
 | 
			
		||||
								for y=1,#clientRequestQueue[Identifier] do
 | 
			
		||||
									local clientRequest = clientRequestQueue[Identifier][y]
 | 
			
		||||
									if not clientRequest then continue end
 | 
			
		||||
									if clientRequest[1] == packetData[1] then
 | 
			
		||||
										Spawn(clientRequest[2], table.unpack(packetData[2]))
 | 
			
		||||
										table.remove(clientRequestQueue[Identifier], y)
 | 
			
		||||
										break
 | 
			
		||||
									end
 | 
			
		||||
								end
 | 
			
		||||
							end
 | 
			
		||||
						end
 | 
			
		||||
| 
						 | 
				
			
			@ -262,17 +267,20 @@ function ClientProcess.start()
 | 
			
		|||
		if not queueIn[Identifier] then
 | 
			
		||||
			queueIn[Identifier] = {}
 | 
			
		||||
		end
 | 
			
		||||
		if logger[Identifier] then
 | 
			
		||||
			task.defer(Logger.write, Identifier, `state: in -> net -> {#data} data.`)
 | 
			
		||||
		end
 | 
			
		||||
		if not clientCallback[Identifier] then
 | 
			
		||||
			if not incoming_cache[Identifier] then
 | 
			
		||||
				incoming_cache[Identifier] = {}
 | 
			
		||||
			end
 | 
			
		||||
			table.insert(incoming_cache[Identifier], data)
 | 
			
		||||
			if logger[Identifier] then
 | 
			
		||||
				task.defer(Logger.write, Identifier, `state: cache -> net -> {#data} data.`)
 | 
			
		||||
			end
 | 
			
		||||
			return
 | 
			
		||||
		end
 | 
			
		||||
		table.insert(queueIn[Identifier], data)
 | 
			
		||||
		if logger[Identifier] then
 | 
			
		||||
			task.defer(Logger.write, Identifier, `state: in -> net -> {#data} data.`)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	ReliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
 | 
			
		||||
	UnreliableEvent.OnClientEvent:Connect(onClientNetworkReceive)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
--!strict
 | 
			
		||||
--!native
 | 
			
		||||
--!optimize 2
 | 
			
		||||
local RunService = game:GetService("RunService")
 | 
			
		||||
local Type = require(script.Parent.Type)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
--!strict
 | 
			
		||||
--!native
 | 
			
		||||
--!optimize 2
 | 
			
		||||
local Logger = {}
 | 
			
		||||
local Logs: {
 | 
			
		||||
	[string]: {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,6 +109,9 @@ function ServerProcess.insertRequest(Identifier: string, timeout: number, player
 | 
			
		|||
	if not serverQueue[Identifier][player] then
 | 
			
		||||
		serverQueue[Identifier][player] = {}
 | 
			
		||||
	end
 | 
			
		||||
	if not serverRequestQueue[Identifier] then
 | 
			
		||||
		serverRequestQueue[Identifier] = {}
 | 
			
		||||
	end
 | 
			
		||||
	local yieldThread: thread, start = coroutine.running(), os.clock()
 | 
			
		||||
	local cancel = task.delay(timeout, function()
 | 
			
		||||
		task.spawn(yieldThread, nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -201,30 +204,45 @@ function ServerProcess.start()
 | 
			
		|||
		end
 | 
			
		||||
 | 
			
		||||
		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
 | 
			
		||||
			for player, content: any in contents do
 | 
			
		||||
				if #content > 0 and queueOut[player] then
 | 
			
		||||
					ReliableEvent:FireClient(player, Buffer.revert(Identifier), content)
 | 
			
		||||
					serverQueue[Identifier][player] = nil
 | 
			
		||||
				end
 | 
			
		||||
				if #serverRequestQueue[Identifier][player] > 0 then
 | 
			
		||||
				serverQueue[Identifier][player] = nil
 | 
			
		||||
				
 | 
			
		||||
				if serverRequestQueue[Identifier][player] then
 | 
			
		||||
					for _, requestData in serverRequestQueue[Identifier][player] do
 | 
			
		||||
						if not requestData[3] then continue end
 | 
			
		||||
						if not queueOutRequest[1][Identifier][player] then
 | 
			
		||||
							queueOutRequest[1][Identifier][player] = {}
 | 
			
		||||
						end
 | 
			
		||||
						table.insert(queueOutRequest[1][Identifier][player], { requestData[1], requestData[3] })
 | 
			
		||||
						serverRequestQueue[Identifier][player] = nil
 | 
			
		||||
					end
 | 
			
		||||
					serverRequestQueue[Identifier][player] = nil
 | 
			
		||||
				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
 | 
			
		||||
					local requestIn1: any = queueInRequest[1][Identifier][player]
 | 
			
		||||
					local requestIn2: any = queueInRequest[2][Identifier][player]
 | 
			
		||||
| 
						 | 
				
			
			@ -283,14 +301,6 @@ function ServerProcess.start()
 | 
			
		|||
						queueInRequest[2][Identifier][player] = nil
 | 
			
		||||
					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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
--!strict
 | 
			
		||||
--!native
 | 
			
		||||
--!optimize 2
 | 
			
		||||
local RateLimit = {}
 | 
			
		||||
 | 
			
		||||
local RunService = game:GetService("RunService")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
--!strict
 | 
			
		||||
--!native
 | 
			
		||||
--!optimize 2
 | 
			
		||||
local RunService = game:GetService("RunService")
 | 
			
		||||
local SerInt = 0
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue