How to use the @xmpp/client.client function in @xmpp/client

To help you get started, we’ve selected a few @xmpp/client 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 / client / example.js View on Github external
/* eslint-disable node/no-extraneous-require */

'use strict'

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

const xmpp = client({
  service: 'ws://localhost:5280/xmpp-websocket',
  domain: 'localhost',
  resource: 'example',
  username: 'username',
  password: 'password',
})

debug(xmpp, true)

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

xmpp.on('offline', () => {
  console.log('offline')
})
github xmppjs / xmpp.js / packages / roster / example.js View on Github external
/* eslint-disable node/no-extraneous-require */

/*
 * This is a complete example of roster management with persistent versioning (caching) support
 * it uses XML serialization and the filesystem for persistence but
 * you can use anything you like such as IndexedDB and JSON as long as the version (ver) is correct
 */

'use strict'

const {client, xml} = require('@xmpp/client')
const debug = require('@xmpp/debug')
const Roster = require('.') // @xmpp/roster
const Storage = require('./Storage') // @xmpp/storage

const xmpp = client({
  // service: 'ws://localhost:5280/xmpp-websocket',
  // domain: 'localhost',
  service: 'localhost',
  username: 'username',
  password: 'password',
})
debug(xmpp, true)

const storage = new Storage(xmpp)

// eslint-disable-next-line new-cap
xmpp.roster = Roster({...xmpp, storage})

xmpp.on('online', async () => {
  const roster = await xmpp.roster.get()
  console.log(
github pazznetwork / ngx-chat / projects / pazznetwork / ngx-chat / src / lib / services / adapters / xmpp / plugins / registration.plugin.ts View on Github external
return new Promise(resolveConnectionEstablished => {
            this.client = client({
                domain: domain || getDomain(service),
                service,
                credentials: async (authenticationCallback) => {
                    resolveConnectionEstablished();
                    await this.registered$.pipe(takeUntil(this.cleanUp), first()).toPromise();
                    await authenticationCallback({username, password});
                }
            });

            this.client.reconnect.stop();
            this.client.timeout = this.registrationTimeout;

            this.client.on('online', () => {
                this.logService.debug('registration plugin', 'online event');
                this.loggedIn$.next();
            });

@xmpp/client

An XMPP client is an entity that connects to an XMPP server.

ISC
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis

Similar packages