Class: Parser

net.Parser(network)

Protocol Message Parser

Constructor

new Parser(network)

Create a parser.

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

Extends

  • EventEmitter

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(type, data) → {Object}

Parse a payload.

Parameters:
Name Type Description
type Number

Packet type.

data Buffer

Payload.

Source:
Returns:
Type
Object