How to use the node-xmpp.Element function in node-xmpp

To help you get started, we’ve selected a few node-xmpp 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 superfeedr / xmpp-server / test / functional / s2s-chat.js View on Github external
it('bernard should get bianca\'s messages', function(done){
        var biancaSays = 'Hello Bernard!';
        bernard.on('stanza', function(stanza) {
            if (stanza.is('message') && new xmpp.JID(stanza.attrs.from).bare().toString() == "bianca@bianca.local" && stanza.getChild('body').getText() == biancaSays) {
                done();
            }
            else {
                throw function() {}; // Bernard didn't get Bianca's Hello.
            }
        });
        bianca.send(new xmpp.Element('message', {to: "bernard@bernard.local"}).c('body').t(biancaSays));
    });
github superfeedr / xmpp-server / modules / presence.js View on Github external
client.on('disconnect', function() {
        // We need to send a  on his behalf
        var stanza = new xmpp.Element('presence', {from: client.jid.toString(), type: "unavailable" });
        client.server.router.connectedClientsForJid(client.jid.toString()).forEach(function(jid) {
            if(client.jid.resource != jid.resource) {
                stanza.attrs.to = jid.toString();
                client.server.emit('inStanza', client, stanza); // TODO: Blocking Outbound Presence Notifications.
            }
        });
        client.roster.eachSubscription(["from", "both"], function(item) {
            stanza.attrs.to = item.jid;
            client.server.emit('inStanza', client, stanza); // TODO: Blocking Outbound Presence Notifications.
        });
    });
}
github superfeedr / xmpp-server / chat.js View on Github external
it('bernard should get bianca\'s messages', function(done){
        var biancaSays = 'Hello Bernard!';
        bernard.on('stanza', function(stanza) {
            if (stanza.is('message') && new xmpp.JID(stanza.attrs.from).bare().toString() == "bianca@localhost" && stanza.getChild('body').getText() == biancaSays) {
                done();
            }
            else {
                throw function() {}; // Bernard didn't get Bianca's Hello.
            }
        });
        bianca.send(new xmpp.Element('message', {to: "bernard@localhost"}).c('body').t(biancaSays));
    });
github superfeedr / xmpp-server / offline.js View on Github external
romeo.on('online', function () {
                romeo.send(new xmpp.Element('presence', {}).c('show').t('chat').up().c('status').t('On the balcony'));
                romeo.send(new xmpp.Element('message', {to: "juliet@localhost"}).c('body').t(romeoSays)); // juliet is not online!
                proceed();
            });
        });
github superfeedr / xmpp-server / offline.js View on Github external
romeo.on('online', function () {
                romeo.send(new xmpp.Element('presence', {}).c('show').t('chat').up().c('status').t('On the balcony'));
                romeo.send(new xmpp.Element('message', {to: "juliet@localhost"}).c('body').t(romeoSays)); // juliet is not online!
                proceed();
            });
        });
github superfeedr / xmpp-server / test / functional / s2s-chat.js View on Github external
bernard.on('online', function () {
                bernard.send(new xmpp.Element('presence', {}).c('show').t('chat').up().c('status').t('Bernard is here to help!'));
                online();
            });
github xmpp-ftw / xmpp-ftw / lib / pubsub.js View on Github external
this.socket.emit('xmpp.pubsub.push.authorisation', data, function(data) {
        var stanza = new builder.Element(
            'message',
            { to: to, id: id }
        )
        dataForm.addForm(stanza, data, this.NS_SUBSCRIPTION_AUTHORISATION)
        this.client.send(stanza)
    })
}
github kartikrustagi / nodejs-xmpp-server / modules / Roster.js View on Github external
client.roster.deleteContact(new xmpp.JID(i.attrs.jid), function(err) {
							var resultStanza = null;
							if(err == null) {
								resultStanza = new xmpp.Element('iq', {'to' : stanza.attrs.from, 'type' : 'result', 'id' : stanza.attrs.id});
							}else {
								resultStanza = new xmpp.Element('iq', {'to' : stanza.attrs.from, 'type' : 'error', 'id' : stanza.attrs.id});
								resultStanza.c("error").c('text', { xmlns: "urn:ietf:params:xml:ns:xmpp-stanzas" }).t(err.message);
							}
							logger.info("Post deleteContact roster");
							client.send(resultStanza);
						});
					} else {
github PaulFreund / i2x / node_modules / xmppHandler.js View on Github external
send = function(outto, message) {
            var out = new xmpp.Element('message', {
                to: outto,
                type: 'chat'
            });
            
            var body = out.c('body');
            body.t(message);
            
            xmppServer.send(out);
        },
github kartikrustagi / nodejs-xmpp-server / modules / Roster.js View on Github external
client.roster.deleteContact(new xmpp.JID(i.attrs.jid), function(err) {
							var resultStanza = null;
							if(err == null) {
								resultStanza = new xmpp.Element('iq', {'to' : stanza.attrs.from, 'type' : 'result', 'id' : stanza.attrs.id});
							}else {
								resultStanza = new xmpp.Element('iq', {'to' : stanza.attrs.from, 'type' : 'error', 'id' : stanza.attrs.id});
								resultStanza.c("error").c('text', { xmlns: "urn:ietf:params:xml:ns:xmpp-stanzas" }).t(err.message);
							}
							logger.info("Post deleteContact roster");
							client.send(resultStanza);
						});
					} else {

node-xmpp

XMPP for JavaScript

ISC
Latest version published 8 years ago

Package Health Score

50 / 100
Full package analysis

Popular node-xmpp functions