Registers a passive listener for incoming packets. The callback receives a packet record. Returns an id for disconnect.
RakNet is off by default. The library exists only when the RakNet feature is enabled in the Athena loader, and it is published on getgenv() rather than as a plain global. Guard your code with if getgenv().raknet then ... end, or read raknet.is_enabled.

Parameters

function
required
Called as callback(record) for each incoming packet.

Returns

number
The listener id, for disconnect.

Behavior

  • Inbound capture depends on the transport. Check stats — the inbound field reports whether inbound interception is active. If it is false, this listener will not be called even though outgoing capture works.
  • Passive only, and errors are logged and skipped.

Example

Errors

  • on_send: the outbound equivalent.
  • stats: check whether inbound capture is live.