Packets Library

zetaepyon edited this page Jan 9, 2018 · 1 revision

This library adds an interface for working with packets. It allows accessing and modifying packets in a table-like structure based on the information in the fields file (Windower/addons/libs/packets/fields.lua).

Usage

packets = require('packets')

Functions

packets.parse(dir, data)

packet = packets.parse(dir, data)
  • packet table - Table containing packet information

  • dir string - Direction, only incoming and outgoing are valid arguments

  • data string - Binary string containing the packet data (including the header)

These functions parse an incoming/outgoing packet (usually from the respective incoming chunk and outgoing chunk events). They return a table populated with everything found about the particular packet in the fields file.

packets.new(dir, id, data)

packet = packets.new(dir, id, data)
  • packet table - Table containing packet information

  • dir string - Direction, only incoming and outgoing are valid arguments

  • data table [optional] - Table containing data to populate the resulting table with

Creates a new packet table with every field in the fields file populated with a default value (0 or ""). If the data argument was provided, the fields in there will overwrite the default values in the created packet.

packets.build(packet)

data = packets.build(packet)
  • packet table - Table containing packet information (as returned by packets.new or packets.parse)

  • data string - Binary string containing the full packet payload (including the header)

Creates a binary string that can be injected in the incoming or outgoing packet facilities. It only fully works with packets that are defined in the fields file, otherwise it won't know which values to populate and how. It also only fully works with packets that contain only a single definition and not multiple definitions which have to be disambiguated based on the provided data, since the data doesn't exist here yet.

packets.inject(packet)

packets.inject(packet)
  • packet table - Table containing packet information (as returned by packets.new or packets.parse)

Injects the packet that was passed to it. It first builds the packet (using packets.build) and then injects the resulting string in either the incoming or outgoing packet handler. This does not have to be specified, as it's included in the packet table when it's created with either packets.new or packets.parse, both of which require a direction argument.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.