Hooks
- Luau
- Typescript
Hooks allow you to integrate YetAnotherNet into any game architecture you want. These are simply functions that you can call whenever you want to process your Packets. It's recommended that you set your hooks to run on the Heartbeat using RunService.Heartbeat
, so your Networking Code can be scheduled to run frame-by-frame as Net was designed to do.
To create a hook, you can use YetAnotherNet.createHook({ Route })
and pass in a table of your Routes, then you can call it whenever you want to process your packets.
local RunService = game:GetService("RunService")
local YetAnotherNet = require("@packages/YetAnotherNet")
local routes = require("@shared/routes")
local hook = YetAnotherNet.createHook(routes)
RunService.Heartbeat:Connect(hook)
Hooks allow you to integrate YetAnotherNet into any game architecture you want. These are simply functions that you can call whenever you want to process your Packets. It's recommended that you set your hooks to run on the Heartbeat using RunService.Heartbeat
, so your Networking Code can be scheduled to run frame-by-frame as Net was designed to do.
To create a hook, you can use YetAnotherNet.createHook({ route: Route })
and pass in an array of your Routes, then you can call it whenever you want to process your packets.
import { RunService } from "@rbxts/services";
import Net from "@rbxts/yetanothernet";
import routes from "shared/routes";
const hook = Net.createHook(routes);
RunService.Heartbeat.Connect(hook);