Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Parser

Wire protocol msg parser

Hierarchy

  • EventEmitter
    • Parser

Index

Constructors

constructor

  • new Parser(framer: Framer, msgHeaderLength?: number, maxBufferSize?: number): Parser

Properties

Private Optional encryptionKey

encryptionKey: Buffer

Private framer

framer: Framer

Private maxBufferSize

maxBufferSize: number

Private msgHeaderLength

msgHeaderLength: number

Private pending

pending: Buffer[] = []

Private waiting

waiting: number = 0

Private waitingHeader

waitingHeader: number = 0

Static Private Readonly MAX_BUFFER_SIZE

MAX_BUFFER_SIZE: number = (4 * 1024 * 1024)

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: keyof symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

emit

  • emit(event: "packet", packet: Packet): boolean
  • emit(event: "error", err: { code: string; message: string }): boolean
  • Parameters

    • event: "packet"
    • packet: Packet

    Returns boolean

  • Parameters

    • event: "error"
    • err: { code: string; message: string }
      • code: string
      • message: string

    Returns boolean

Private error

  • error(err: any): void

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

feed

  • feed(chunk: Buffer): void

getMaxListeners

  • getMaxListeners(): number

Private getTotalSize

  • getTotalSize(chunk: Buffer): number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: "packet", packet: (order: Packet) => void): this
  • on(event: "error", err: (order: { code: string; message: string }) => void): this
  • Parameters

    • event: "packet"
    • packet: (order: Packet) => void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "error"
    • err: (order: { code: string; message: string }) => void
        • (order: { code: string; message: string }): void
        • Parameters

          • order: { code: string; message: string }
            • code: string
            • message: string

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private parseLength

  • parseLength(data: Buffer): number

Private parseMessage

  • parseMessage(chunks: Buffer[]): void

Private parsePacket

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

Private read

  • read(length: number, chunk: Buffer): void

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private resetBuffer

  • resetBuffer(): void

setEncryptionKey

  • setEncryptionKey(key: Buffer): void

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc