Yuari
Documentation
Docs/RakNet/raknet.add_receive_hook

raknet.add_receive_hook

Registers or removes incoming-packet callbacks.

Syntax

raknet.add_receive_hook(fn: function, packetId?: number) -> nil

Parameters

ParameterTypeDescription
fnfunctionThe function or callback to use.
packetId?numberThe RakNet packet id to match, or nil for every packet.

Returns

TypeDescription
nilThis 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.