packet_object - Windower/packages GitHub Wiki
A packet object is a struct_object returned from the packet parser. It analyses incoming and outgoing packets and parses them according to the definition in the types.lua
file. The technical metadata of the packet is not part of this. It is passed to a registered function as the second parameter.
Assume you register the following function:
local packets = require('packets')
packets.incoming[0x017]:register(fn)
The incoming packet 0x017
is defined as follows in the types.lua
file:
-- Incoming Chat
types.incoming[0x017] = struct({
chat = {0x00, chat},
gm = {0x01, boolbit(uint8), offset=0},
formatted = {0x01, boolbit(uint8), offset=3},
zone = {0x02, zone},
name = {0x04, pc_name},
message = {0x14, string(0xEC)},
})
Now the fn
function might receive the following struct as the first parameter:
{
-- Content data, only provided based on what is defined in the types.lua
chat = 1, -- /say
gm = true, -- Sent by a GM
formatted = false, -- No specific formatting
zone = 0, -- This parameter is only set during /yell
name = 'Dave', -- Name of the sender
message = 'Jormy is looking forward to you...', -- Message
}
And this info would be the second parameter:
{
-- Technical data, always provided
modified = '...', -- binary string
modified_size = 256,
original = '...', -- binary string
original_size = 256,
id = 23,
direction = 'incoming',
timestamp = 123456789,
blocked = false,
injected = false,
path = '/incoming/23',
}