raknet.addreceivehook
Registers a callback for incoming packet snapshots.
Syntax
raknet.addreceivehook(callback: function) -> boolean
Also available as
raknet.add_receive_hook
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | function | Function accepting one packet object. |
Returns
| Type | Description |
|---|---|
boolean | True when the callback is registered. |
Description
The callback receives a RakNetPacket with byte representations and metadata. Incoming data has already been received by the game. These callbacks observe snapshots and cannot block or replace that traffic. Retain the same callback function to remove it later. Unsupported sessions raise a clear error rather than pretending the callback was installed.
Example
local function inspect(packet)
print(packet.Direction, packet.Size)
end
raknet.addreceivehook(inspect)
raknet.removereceivehook(inspect)
These are Game executor contracts. Check build requirements and session lifetimes before using them.
