raknet.add_receive_hook
Registers or removes incoming-packet callbacks.
Syntax
raknet.add_receive_hook(fn: function, packetId?: number) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | function | The function or callback to use. |
packetId? | number | The RakNet packet id to match, or nil for every packet. |
Returns
| Type | Description |
|---|---|
nil | This function does not return a value. |
Description
raknet.add_receive_hook is part of the RakNet library. RakNet helpers expose the client's network stream: packet hooks, capture controls and bitstream serialization.
The operation is performed immediately using the arguments supplied at the call site.
The aliases receive, addreceivehook, remove_receive_hook, removereceivehook resolve to the same implementation.
Example
local id = raknet.add_receive_hook(function(packet)
print(packet)
end, 0x1B)
raknet.remove_receive_hook(id)
Notes
- Aliases:
receive,addreceivehook,remove_receive_hook,removereceivehook. - Packet hooks run on the network path and should return quickly.