]> git.lizzy.rs Git - hydra-dragonfire.git/blob - doc/pkts.md
fba5083194f750faebe5cf7a09f0c5a860183cd5
[hydra-dragonfire.git] / doc / pkts.md
1 # Packet Handler Component
2 Source code: [pkts.go](../pkts.go)
3
4 The packet handler component allows you to handle packets yourself. It fires events in the form of `{ type = "pkt", client = ..., pkt_type = "...", pkt_data = { ... } }``` when subscribed packets are received.
5 For available packets, see [client_pkts.md](client_pkts.md). By default, not packets are packets subscribed.
6
7 ## Wildcard mode
8
9 If wildcard is enabled, events for all packets are fired, even ones that are not subscribed. It is not recommended to use this without a reason since converting packets to Lua costs performance and creates and overhead due to poll returning more often. `wildcard` is unnecessary if only certain packets are handled anyway, but it is useful for traffic inspection and debugging.
10
11 ## Functions
12
13 - `self:subscribe(pkt1, [pkt2, ...])`: Subscribes to all packet types passed as arguments (strings).
14
15 - `self:unsubscribe(pkt1, [pkt2, ...])`: Unsubscribes from all packet passed as arguments (strings).
16
17 - `self:wildcard(wildcard)`: Sets wildcard mode to `wildcard` (boolean).
18