Class NiimbotAbstractClientAbstract

Abstract class representing a client with common functionality for interacting with a printer. Hardware interface must be defined after extending this class.

Hierarchy (view full)

Constructors

Properties

abstraction: Abstraction
debug: boolean = false
info: PrinterInfo = {}
mutex: Mutex = ...
packetIntervalMs: number = 10
prefixed: string | boolean

Methods

  • Type Parameters

    Parameters

    Returns this

  • Disconnect from printer port.

    Returns Promise<void>

  • Calls each of the listeners registered for a given event.

    Type Parameters

    Parameters

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (keyof ClientEventMap)[]

  • Determine print task version if any.

    Returns
        | undefined
        | "B1"
        | "D110"
        | "D11_V1"
        | "B21_V1"
        | "V5"

  • Send "connect" packet and fetch the protocol version.

    Returns Promise<void>

  • Checks if the heartbeat timer has been started.

    Returns boolean

  • Return the number of listeners listening to a given event.

    Parameters

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    Parameters

    • event: T

    Returns ((...args: ArgumentMap<ClientEventMap>[Extract<T, keyof ClientEventMap>]) => void)[]

  • Type Parameters

    Parameters

    Returns this

  • Add a listener for a given event.

    Type Parameters

    Parameters

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    Parameters

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optionalevent: keyof ClientEventMap

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    Parameters

    Returns this

  • Send raw bytes to the printer port.

    Parameters

    • data: Uint8Array

      Bytes to send.

    • Optionalforce: boolean

      Ignore mutex lock. It used internally and you should avoid using it.

    Returns Promise<void>

  • Enable some debug information logging.

    Parameters

    • value: boolean

    Returns void

  • Set the interval between packets in milliseconds.

    Parameters

    • milliseconds: number

    Returns void

  • Stops the heartbeat by clearing the interval timer.

    Returns void