local p=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local M=require(p.Packages.BridgeNet)local R=true local t="\114\111\098\108\111\120"if not R then local p=M.CreateUUID()print(p)local R=M.PackUUID(p)print(R)print(M.UnpackUUID(R))local t=M.Identifiers({"\084\101\115\116";"\070\117\110\110\121";"\072\097\104\097";"\084\101\115\116\066";"\121\101\115"})print(t)local m=M.CreateBridgeTree({RemoteA=M.Bridge({ReplicationRate=20}),RemoteCategory={RemoteB=M.Bridge({ReplicationRate=45,Server={OutboundMiddleware={function(...)print("\067\114\101\097\116\101\066\114\105\100\103\101\084\114\101\101 \115\101\114\118\101\114 \109\105\100\100\108\101\119\097\114\101 \111\117\116\103\111\105\110\103")return...end};InboundMiddleware={function(p,...)print("\067\114\101\097\116\101\066\114\105\100\103\101\084\114\101\101 \115\101\114\118\101\114 \109\105\100\100\108\101\119\097\114\101 \105\110\098\111\117\110\100\058 "..p.Name)return...end}};Client={OutboundMiddleware={function(...)print("\067\114\101\097\116\101\066\114\105\100\103\101\084\114\101\101 \099\108\105\101\110\116 \109\105\100\100\108\101\119\097\114\101 \111\117\116\103\111\105\110\103")return...end},InboundMiddleware={function(...)print("\067\114\101\097\116\101\066\114\105\100\103\101\084\114\101\101 \099\108\105\101\110\116 \109\105\100\100\108\101\119\097\114\101 \105\110\098\111\117\110\100")return...end}}}),RemoteC=M.Bridge({})}})if m.RemoteA==nil then error("\046\068\101\099\108\097\114\101 \101\114\114\111\114\044 \082\101\109\111\116\101\065 \105\115 \110\105\108")end if m.RemoteCategory==nil then error("\082\101\109\111\116\101\067\097\116\101\103\111\114\121 \105\115 \110\105\108")end if m.RemoteCategory.RemoteB==nil then error("\046\068\101\099\108\097\114\101 \101\114\114\111\114\044 \082\101\109\111\116\101\066 \105\115 \110\105\108")end if m.RemoteA._id==nil and m.RemoteA._name==nil then error("\046\068\101\099\108\097\114\101 \100\111\101\115 \110\111\116 \114\101\116\117\114\110 \097 \098\114\105\100\103\101")end local T=m.RemoteA:Connect(function(p)print(p)end)m.RemoteCategory.RemoteB:Connect(function() end)local O=0 M.ReplicationStep(20,function()print(os.clock()-O)O=os.clock()end)task.delay(5,function()T:Disconnect()end)while true do m.RemoteCategory.RemoteB:Fire("\099\108\105\101\110\116 \116\111 \115\101\114\118\101\114 \099\104\101\099\107")m.RemoteCategory.RemoteB:InvokeServerAsync("\065\114\103\115 \119\111\114\107\105\110\103")task.wait(2)end elseif R then if t=="\098\114\105\100\103\101\110\101\116"then local p=M.CreateBridge("\115\116\114\101\115\115\101\114")p:Connect(function() end)elseif t=="\114\111\098\108\111\120"then local M=p:WaitForChild("\084\101\115\116\069\118\101\110\116")M.OnClientEvent:Connect(function() end)end end
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local BridgeNet = require(ReplicatedStorage.Packages.BridgeNet)

local STRESS_TEST = true
local BRIDGENET_OR_ROBLOX = "roblox"

if not STRESS_TEST then
	local uuid = BridgeNet.CreateUUID()
	print(uuid)
	local packed = BridgeNet.PackUUID(uuid)
	print(packed)
	print(BridgeNet.UnpackUUID(packed))

	local Identifiers = BridgeNet.Identifiers({
		"Test",
		"Funny",
		"Haha",
		"TestB",
		"yes",
	})
	print(Identifiers)

	local Bridges = BridgeNet.CreateBridgeTree({
		RemoteA = BridgeNet.Bridge({
			ReplicationRate = 20,
		}),
		RemoteCategory = {
			RemoteB = BridgeNet.Bridge({
				ReplicationRate = 45,
				Server = {
					OutboundMiddleware = {
						function(...)
							print("CreateBridgeTree server middleware outgoing")
							return ...
						end,
					},
					InboundMiddleware = {
						function(plr, ...)
							print("CreateBridgeTree server middleware inbound: " .. plr.Name)
							return ...
						end,
					},
				},
				Client = {
					OutboundMiddleware = {
						function(...)
							print("CreateBridgeTree client middleware outgoing")
							return ...
						end,
					},
					InboundMiddleware = {
						function(...)
							print("CreateBridgeTree client middleware inbound")
							return ...
						end,
					},
				},
			}),
			RemoteC = BridgeNet.Bridge({}),
		},
	})

	if Bridges["RemoteA"] == nil then
		error(".Declare error, RemoteA is nil")
	end

	if Bridges["RemoteCategory"] == nil then
		error("RemoteCategory is nil")
	end

	if Bridges.RemoteCategory["RemoteB"] == nil then
		error(".Declare error, RemoteB is nil")
	end

	if Bridges.RemoteA["_id"] == nil and Bridges.RemoteA["_name"] == nil then
		error(".Declare does not return a bridge")
	end

	local connection = Bridges.RemoteA:Connect(function(arg1)
		print(arg1)
	end)

	Bridges.RemoteCategory.RemoteB:Connect(function() end)

	local lastTwentyHz = 0
	BridgeNet.ReplicationStep(20, function()
		print(os.clock() - lastTwentyHz)
		lastTwentyHz = os.clock()
	end)

	task.delay(5, function()
		connection:Disconnect()
	end)

	while true do
		Bridges.RemoteCategory.RemoteB:Fire("client to server check")
		Bridges.RemoteCategory.RemoteB:InvokeServerAsync("Args working")
		task.wait(2)
	end
elseif STRESS_TEST then
	if BRIDGENET_OR_ROBLOX == "bridgenet" then
		local stresser = BridgeNet.CreateBridge("stresser")

		stresser:Connect(function() end)
	elseif BRIDGENET_OR_ROBLOX == "roblox" then
		local stresser = ReplicatedStorage:WaitForChild("TestEvent")

		stresser.OnClientEvent:Connect(function() end)
	end
end
