How to use the @xmpp/events.promise function in @xmpp/events

To help you get started, we’ve selected a few @xmpp/events 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 / connection / index.js View on Github external
async close(timeout = this.timeout) {
    const p = Promise.all([
      promise(this.parser, 'end', 'error', timeout),
      this.write(this.footer(this.footerElement())),
    ])

    if (this.parser && this.socket) this._status('closing')
    const [el] = await p
    this.root = null
    return el
    // The 'close' status is set by the parser 'end' listener
  }
github xmppjs / xmpp.js / packages / connection / index.js View on Github external
async disconnect(timeout = this.timeout) {
    if (this.socket) this._status('disconnecting')

    this.socket.end()

    // The 'disconnect' status is set by the socket 'close' listener
    await promise(this.socket, 'close', 'error', timeout)
  }
github xmppjs / xmpp.js / packages / connection / index.js View on Github external
async _onSeeOtherHost(error) {
    const {protocol} = parseService(this.options.service)

    const host = error.element.getChildText('see-other-host')
    const {port} = parseHost(host)

    let service
    if (port) {
      service = `${protocol || 'xmpp:'}//${host}`
    } else {
      service = (protocol ? `${protocol}//` : '') + host
    }

    try {
      await promise(this, 'disconnect')
      const {domain, lang} = this.options
      await this.connect(service)
      await this.open({domain, lang})
    } catch (err) {
      this.emit('error', err)
    }
  }
github xmppjs / xmpp.js / packages / connection / index.js View on Github external
if (typeof options === 'string') {
      options = {domain: options}
    }

    const {domain, lang, timeout = this.timeout} = options

    const headerElement = this.headerElement()
    headerElement.attrs.to = domain
    headerElement.attrs['xml:lang'] = lang
    this.root = headerElement

    this._attachParser(new this.Parser())

    await this.write(this.header(headerElement))
    return promise(this, 'open', 'error', timeout)
  }

@xmpp/events

XMPP events utilities.

ISC
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis