Class: Parser

net.Parser

new Parser(network)

Protocol packet parser

Parameters:
Name Type Description
network Network
Source:
Fires:
  • Parser#event:error
  • Parser#event:packet

Methods

(private) error(…msg)

Emit an error.

Parameters:
Name Type Attributes Description
msg String <repeatable>
Source:

feed(data)

Feed data to the parser.

Parameters:
Name Type Description
data Buffer
Source:

parse(chunk)

Parse a fully-buffered chunk.

Parameters:
Name Type Description
chunk Buffer
Source:

parseHeader(data) → {Header}

Parse buffered packet header.

Parameters:
Name Type Description
data Buffer

Header.

Source:
Returns:
Type
Header

parsePayload(cmd, data) → {Object}

Parse a payload.

Parameters:
Name Type Description
cmd String

Packet type.

data Buffer

Payload.

Source:
Returns:
Type
Object