How to use the mqtt-packet.parser function in mqtt-packet

To help you get started, we’ve selected a few mqtt-packet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linksmart / border-gateway / bgw-mqtt-proxy / index.js View on Github external
dstClient.on("connect", () => {
        const srcParser = mqtt.parser(opts);
        const dstParser = mqtt.parser(opts);
        // const noopParser = mqtt.parser(opts);
        //
        // noopParser.on('packet', (packet) => {
        //     logger.log('debug', "packet event emitted on noopParser", {packet: packet});
        // });
        //
        // noopParser.on('error', (error) => {
        //     logger.log('debug', "error event emitted on noopParser", {errorMessage: error.message});
        // });

        srcClient.on('data', (data) => {
            logger.log('debug', "srcClient has data", {data: data});
            try {
                srcParser.parse(data);
            } catch (err) {
                logger.log('error', "Parse error in srcParser", {errorName: err.name, errorMessage: err.message});
github mcollina / aedes / lib / client.js View on Github external
function Client (broker, conn, req) {
  var that = this

  this.broker = broker
  this.conn = conn
  this.req = req
  this.parser = mqtt.parser()
  this.connected = false
  this.connackSent = false
  this.errored = false
  this.clean = true
  this._handling = 0
  this.subscriptions = {}
  this.id = null

  // we use two variables for the will
  // because we store in _will while
  // we are authenticating
  this.will = null
  this._will = null

  conn.client = this
github linksmart / border-gateway / bgw-mqtt-proxy / index.js View on Github external
dstClient.on("connect", () => {
        const srcParser = mqtt.parser(opts);
        const dstParser = mqtt.parser(opts);
        // const noopParser = mqtt.parser(opts);
        //
        // noopParser.on('packet', (packet) => {
        //     logger.log('debug', "packet event emitted on noopParser", {packet: packet});
        // });
        //
        // noopParser.on('error', (error) => {
        //     logger.log('debug', "error event emitted on noopParser", {errorMessage: error.message});
        // });

        srcClient.on('data', (data) => {
            logger.log('debug', "srcClient has data", {data: data});
            try {
                srcParser.parse(data);
            } catch (err) {
github Rodmg / aquila-mqtt-sn-gateway / node_modules / mqtt / lib / client.js View on Github external
MqttClient.prototype._setupStream = function () {
  var connectPacket,
    that = this,
    writable = new Writable(),
    parser = mqttPacket.parser(this.options),
    completeParse = null,
    packets = [];

  this._clearReconnect();

  this.stream = this.streamBuilder(this);

  parser.on('packet', function (packet) {
    packets.push(packet);
  });

  function process () {
    var packet = packets.shift(),
      done = completeParse;
    if (packet) {
      that._handlePacket(packet, process);
github mqttjs / mqtt-connection / lib / parseStream.js View on Github external
function createParser (opts) {
    that.parser = build(opts)
    that.parser.on('packet', push)
    that.parser.on('error', that.stream.emit.bind(that.stream, 'error'))
  }
github mqttjs / mqtt-stack / src / client.js View on Github external
constructor(stack, stream) {
        super();
        let self = this;

        this.stack = stack;
        this.stream = stream;
        this._parser = mqtt.parser();
        this._workload = 1;
        this._dead = false;

        this.stack.install(this);

        stream.on('readable', self._work.bind(self));
        stream.on('error', this.emit.bind(this, 'error'));
        stream.on('close', this.emit.bind(this, 'close'));

        this._parser.on('packet', function (packet) {
            self._workload++;
            stack.process(self, packet, self._work.bind(self));
        });

        this._parser.on('error', this.emit.bind(this, 'error'));
github mqttjs / MQTT.js / lib / client.js View on Github external
MqttClient.prototype._setupStream = function () {
  var connectPacket
  var that = this
  var writable = new Writable()
  var parser = mqttPacket.parser(this.options)
  var completeParse = null
  var packets = []

  this._clearReconnect()

  this.stream = this.streamBuilder(this)

  parser.on('packet', function (packet) {
    packets.push(packet)
  })

  function nextTickWork () {
    if (packets.length) {
      process.nextTick(work)
    } else {
      var done = completeParse
github noahziheng / freeiot / firmware / nodejs / node_modules / mqtt / lib / client.js View on Github external
MqttClient.prototype._setupStream = function () {
  var connectPacket
  var that = this
  var writable = new Writable()
  var parser = mqttPacket.parser(this.options)
  var completeParse = null
  var packets = []

  this._clearReconnect()

  this.stream = this.streamBuilder(this)

  parser.on('packet', function (packet) {
    packets.push(packet)
  })

  function process () {
    var packet = packets.shift()
    var done = completeParse

    if (packet) {

mqtt-packet

Parse and generate MQTT packets like a breeze

MIT
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis