raknet. OnPacketSend: Wait Asynchronous
RakNet.OnPacketSend:Wait
Wait for the next outgoing packet without writing a persistent callback. Unlike a callback’s live view, the returned snapshot remains usable after the wait completes.
Luau
raknet.OnPacketSend:Wait() -> PacketSnapshotParameters
Call this method with a raknet.OnPacketSend receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
This function takes no arguments.
Returns
PacketSnapshotAn owned PacketSnapshot table with copied Data and packet metadata.
Luau
PacketSnapshot = {
Data: buffer, Priority: number, Reliability: number, OrderingChannel: number,
SystemIdentifier: string, Broadcast: boolean, ForceReceiptNumber: number
}Usage notes
The RakNet library must be enabled in Environment settings and connected to an active game generation.
This yields until a packet is observed; arrange a cancellation policy in longer-lived tooling.
Availability
RakNet is disabled by default. RakNet and raknet are removed when the setting is off; retained references can still call is_enabled().
Example
Luau
if raknet.is_enabled() then
task.spawn(function()
local packet = raknet.OnPacketSend:Wait()
print("Next outgoing payload bytes:", buffer.len(packet.Data))
end)
end