How to use the @xmpp/xml.Stanza function in @xmpp/xml

To help you get started, we’ve selected a few @xmpp/xml 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 xmppjs / xmpp.js / packages / streamparser / index.js View on Github external
this.parser.on('startElement', (name, attrs) => {
    if (!self.element) {
      self.emit('startElement', name, attrs)
      self.emit('start', new Element(name, attrs))
    }

    // TODO: refuse anything but 
    if (!self.element && (name === 'stream:stream')) {
      self.emit('streamStart', attrs)
    } else {
      let child
      if (!self.element) { // eslint-disable-line no-negated-condition
        /* A new stanza */
        child = new Stanza(name, attrs)
        self.element = child
        /* For maxStanzaSize enforcement */
        self.bytesParsedOnStanzaBegin = self.bytesParsed
      } else {
        /* A child element of a stanza */
        child = new ElementInterface(name, attrs)
        self.element = self.element.cnode(child)
      }
    }
  })