Skip to main content

Other Setups

You can integrate YetAnotherNet into whatever game architecture you want by creating a Hook using YetAnotherNet.createHook({ Route }) which is identical to the YetAnotherNet.start(loop, { Route }) function. This function will return another function which you can call whenever you want to process your Routes' queues and send/receive your Packets on the Server or Client.

Below is a simple example of creating custom scheduling behavior using YetAnotherNet.createHook({ Route }),

local RunService = game:GetService("RunService")

local YetAnotherNet = require("@packages/YetAnotherNet")
local routes = require("@shared/routes")

local myRoute = routes.myRoute

local beginFrame, endFrame = YetAnotherNet.createHook({ Route })
RunService.Heartbeat:Connect(function()
beginFrame()

myRoute:send(...)
for i, player, data in myRoute:query() do
-- Do something
end

endFrame()
end)