How to use @xmpp/connection - 4 common examples

To help you get started, we’ve selected a few @xmpp/connection 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 / resolve / index.js View on Github external
throw new Error("Couldn't connect")
  }

  const uri = uris.shift()
  const Transport = entity._findTransport(uri)

  if (!Transport) {
    return fallbackConnect(entity, uris)
  }

  entity._status('connecting', uri)
  const params = Transport.prototype.socketParameters(uri)
  const socket = new Transport.prototype.Socket()

  try {
    await socketConnect(socket, params)
    // eslint-disable-next-line no-unused-vars
  } catch (err) {
    return fallbackConnect(entity, uris)
  }

  entity._attachSocket(socket)
  socket.emit('connect')
  /* eslint-disable require-atomic-updates */
  entity.Transport = Transport
  entity.Socket = Transport.prototype.Socket
  entity.Parser = Transport.prototype.Parser
  /* eslint-enable require-atomic-updates */
}
github xmppjs / xmpp.js / packages / plugins / resolve / index.js View on Github external
if (uris.length === 0) {
    throw new Error("Couldn't connect")
  }

  const uri = uris.shift()
  const Transport = entity._findTransport(uri)

  if (!Transport) {
    return fallbackConnect(entity, uris)
  }

  const params = Transport.prototype.socketParameters(uri)
  const socket = new Transport.prototype.Socket()

  try {
    await socketConnect(socket, params)
  } catch (err) {
    return fallbackConnect(entity, uris)
  }

  entity._attachSocket(socket)
  socket.emit('connect')
  entity.Transport = Transport
  entity.Socket = Transport.prototype.Socket
  entity.Parser = Transport.prototype.Parser
}
github xmppjs / xmpp.js / packages / tls / lib / Connection.js View on Github external
socketParameters(service) {
    const {port, hostname, protocol} = parseURI(service)
    return protocol === 'xmpps:'
      ? {port: Number(port) || 5223, host: hostname}
      : undefined
  }
}
github xmppjs / xmpp.js / packages / connection-tcp / index.js View on Github external
socketParameters(service) {
    const {port, hostname, protocol} = parseURI(service)

    return protocol === 'xmpp:'
      ? {port: port ? Number(port) : null, host: hostname}
      : undefined
  }

@xmpp/connection

XMPP connection for JavaScript

ISC
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis