Git Product home page Git Product logo

jxt-xmpp's Introduction

JXT-XMPP

This is a collection of JXT (JSON/XML translator) definitions for XMPP.

These definitions were originally part of the Stanza.io XMPP library, but have been split off into their own module so that they can be used with other projects (such as the node-xmpp family of libraries).

Getting Started

The basic boilerplate to start using the XMPP definitions is:

// Create registry and load required helper plugin
var JXT = require('jxt').createRegistry();
JXT.use(require('jxt-xmpp-types'));

// Load the XMPP definitions
JXT.use(require('jxt-xmpp'));

var stanza = JXT.parse('<message xmlns="jabber:client"><body>Hi!</body></message>');
console.log(stanza.body);
// -> Hi!

var Message = JXT.getMessage();
var msg = new Message({ body: 'Hey' });
console.log(msg.toString());
// -> '<message xmlns="jabber:client"><body>Hey</body></message>'

Here we created our JXT registry, and first loaded the jxt-xmpp-types plugin to provide some required JXT helper types and methods.

With that bit of setup out of the way, we can load the jxt-xmpp module itself.

License

MIT

Created By

If you like this, follow @lancestout on twitter.

jxt-xmpp's People

Contributors

abdurrahmanekr avatar genric avatar juliendangers avatar konradkierus avatar legastero avatar lheckemann avatar luelistan avatar raphiz avatar shoestringresearch avatar sstrigler avatar tylorr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jxt-xmpp's Issues

Extending core stanzas

Hi Lance, i already wrote some custom IQ extensions with JXT, but i can't find out how to extend top level stanza fileds?
For example i want to add attributes to top level message among from to type etc, it it possible?

Report pubsub unsupported feature

When we get a feature-not-implemented error for pubsub would it be possible to report the feature attribute on the unsupported tag? Right now we only get a pubsubCondition: unsupported but it doesn't specify which feature.

pubsub create instant node

Pubsub allows the creation of instant nodes where you do not provide a node attribute on the create tag as shown here: https://xmpp.org/extensions/xep-0060.html#example-130

It doesn't seem possible right now to create a stanza with a create tag that doesn't have a node attribute.

I'm not sure what needs to be changed to implement this but I noticed here https://github.com/otalk/jxt/blob/8c8ddf81c1ba91cb32fdecbfbf6d468b36682b3c/lib/helpers.js#L92-L96 that when setting a sub attribute the element is only created if the value evaluates to truthy.

Changing it to the following would fix this problem but I'm not sure how this would affect other parts of the code base.

sub = exports.createElement(NS, sub, xml.namespaceURI);
if (value) {
    sub.setAttribute(attr, value);
}
xml.appendChild(sub);

'types is not defined' error in blocking.js

When I try to use client.unblock() in stanza.io, I get an Uncaught ReferenceError in `src/blocking.js':

types is not defined

types is indeed not defined in this file. I think this should be Utils instead.

PubSub is not defined

vue.esm.js?65d7:566 ReferenceError: PubSub is not defined
at exports.default (pubsubOwner.js?3378:107)
at JXT.use (index.js?c76b:26)
at exports.default (index.js?5fb2:305)
at JXT.use (index.js?c76b:26)
at new Client (client.js?9ce5:64)
at Object.exports.createClient (index.js?73af:10)
at VueComponent.connectToServer ()

this is found in file pubsubOwner.js

setAttribute

Hi,

How can one add attribute (new field)
to existing element

for example (which is also might be a bug -when downloading stanza.io)
the plugin declare

var Affiliation = JXT.define({
name: 'affiliation',
namespace: _xmppConstants.Namespace.PUBSUB_OWNER,
element: 'affiliation',
fields: {
node: Utils.attribute('node'),
type: Utils.attribute('affiliation'),

    }
});

I want to extend it to be

var Affiliation = JXT.define({
name: 'affiliation',
namespace: _xmppConstants.Namespace.PUBSUB_OWNER,
element: 'affiliation',
fields: {
node: Utils.attribute('node'),
type: Utils.attribute('affiliation'),
//added field
jid: Utils.jidAttribute('jid')
}
});

something like:

jxt.withDefinition('affiliation', NS, function (affiliation) {
//what do I do here?
});

thanks,
Lior

Data channel descriptions

@legastero I have this added to jingle-stanza which helps define data descriptions in jingle contents. Would this fit into this project?

    var DCNS = 'urn:xmpp:jingle:transports:webrtc-datachannel:0';
    var DataChannel = stanza.define({
        name: '_datachannel',
        namespace: DCNS,
        element: 'description',
        tags: ['jingle-description'],
        fields: {
            descType: {value: 'datachannel'}
        }
    });

   ...

    stanza.withDefinition('content', 'urn:xmpp:jingle:1', function (Content) {
        stanza.extend(Content, RTP);
        stanza.extend(Content, DataChannel);
    });

extendIQ is not defined.

I'm not finding any reference to extendIQ on JXT, but this project is using it - was that something that was removed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.