How to use @xmpp/component - 4 common examples

To help you get started, we’ve selected a few @xmpp/component 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 / component / example.js View on Github external
xmpp.on('online', async address => {
  console.log('online as', address.toString())

  // Sends a chat message to itself
  const message = xml(
    'message',
    {type: 'chat', to: address},
    xml('body', {}, 'hello world')
  )
  await xmpp.send(message)
})
github xmppjs / xmpp.js / packages / component / example.js View on Github external
xmpp.on('online', async address => {
  console.log('online as', address.toString())

  // Sends a chat message to itself
  const message = xml(
    'message',
    {type: 'chat', to: address},
    xml('body', {}, 'hello world')
  )
  await xmpp.send(message)
})
github xmppjs / xmpp.js / packages / component / example.js View on Github external
/* eslint-disable node/no-extraneous-require */

'use strict'

const {component, xml} = require('@xmpp/component')
const debug = require('@xmpp/debug')

const xmpp = component({
  service: 'xmpp://localhost:5347',
  domain: 'component.localhost',
  password: 'mysecretcomponentpassword',
})

debug(xmpp, true)

xmpp.on('error', err => {
  console.error(err)
})

xmpp.on('offline', () => {
  console.log('offline')
})

xmpp.on('stanza', async stanza => {
github xmppjs / xmpp.js / packages / console / cli.js View on Github external
module.exports = function(flags, endpoint) {
  const options = {
    input: process.stdin,
    output: process.stdout,
    prompt: chalk.magenta.bold('✏ '),
  }
  if (Number(process.env.NODE_NO_READLINE)) {
    options.terminal = false
  }
  const rl = readline.createInterface(options)

  let prevent = false

  let entity
  if (flags.type === 'compomnent') {
    entity = component.xmpp().component
  } else {
    entity = client.xmpp().client
  }

  const xconsole = new Console(entity)
  xconsole.resetInput = function() {
    rl.prompt()
  }
  xconsole.log = function(...args) {
    readline.cursorTo(process.stdout, 0)
    console.log(...args)
    rl.prompt()
  }
  xconsole.info = function(...args) {
    this.log(chalk.cyan.bold('🛈'), ...args)
  }

@xmpp/component

XMPP component for JavaScript

ISC
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis