Other Setups
- Luau
- Typescript
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)
You can integrate YetAnotherNet into whatever game architecture you want by creating a Hook using Net.createHook({ route: Route })
which is identical to the Net.start(loop, { route: 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 Net.createHook({ route: Route })
,
import { RunService } from "@rbxts/services";
import Net from "@rbxts/yetanothernet";
import routes from "shared/routes";
const myRoute = routes.myRoute;
const beginFrame, endFrame = Net.createHook(routes);
RunService.Heartbeat.Connect(() => {
beginFrame();
myRoute.send(...)
for (const [pos, sender, ...] of myRoute.query()) {
// Do something
}
endFrame();
});