packets module

RawPacket

class RawPacket(transport, data)

RawPacket is used to test the transport’s error handling of malformed packets, by writing data directly onto the stream.

Arguments:
  • transport – DebuggerTransport The transport instance that will own the packet.
  • data – string The raw string to send out onto the stream.

Packet

class Packet(transport)

A generic Packet processing object (extended by two subtypes below).

Packet.fromHeader(header, transport)

Attempt to initialize a new Packet based on the incoming packet header we’ve received so far. We try each of the types in succession, trying JSON packets first since they are much more common.

Arguments:
  • header (string) – Packet header string to attempt parsing.
  • transport (DebuggerTransport) – Transport instance that will own the packet.
Returns:

Packet – Parsed packet of the matching type, or null if no types matched.

JSONPacket

class JSONPacket(transport)

With a JSON packet (the typical packet type sent via the transport), data is transferred as a JSON packet serialized into a string, with the string length prepended to the packet, followed by a colon ([length]:[packet]). The contents of the JSON packet are specified in the Remote Debugging Protocol specification.

Arguments:
  • transport (DebuggerTransport) – Transport instance that will own the packet.
JSONPacket.fromHeader(header, transport)

Attempt to initialize a new JSONPacket based on the incoming packet header we’ve received so far.

Arguments:
  • header (string) – Packet header string to attempt parsing.
  • transport (DebuggerTransport) – Transport instance that will own the packet.
Returns:

JSONPacket – Parsed packet, or null if it’s not a match.

BulkPacket

class BulkPacket(transport)

With a bulk packet, data is transferred by temporarily handing over the transport’s input or output stream to the application layer for writing data directly. This can be much faster for large data sets, and avoids various stages of copies and data duplication inherent in the JSON packet type. The bulk packet looks like:

bulk [actor] [type] [length]:[data]

The interpretation of the data portion depends on the kind of actor and the packet’s type. See the Remote Debugging Protocol Stream Transport spec for more details.

Arguments:
  • transport (DebuggerTransport) – Transport instance that will own the packet.
BulkPacket.fromHeader(header, transport)

Attempt to initialize a new BulkPacket based on the incoming packet header we’ve received so far.

Arguments:
  • header (string) – Packet header string to attempt parsing.
  • transport (DebuggerTransport) – Transport instance that will own the packet.
Returns:

BulkPacket – Parsed packet, or null if it’s not a match.