Skip to content

confcompass/ti-simple-xmpp

Repository files navigation

Titanium Simple XMPP

Simple High Level Titanium XMPP Library (ported from node-simple-xmpp).

Install

Copy the ti-simple-xmpp-commonjs-0.0.1.zip file into the root folder of your Titanium project.

Then modify tiapp.xml to include the following module requirement:

<module platform="commonjs">ti-simple-xmpp</module>

Additionally, the library requires the presence of the Websockets for Titanium library. The module must be added to tiapp.xml as well:

<module platform="iphone">net.iamyellow.tiws</module>

Building

If any source code file or dependency has changed, the Zip file must be rebuilt.

First, obtain all required NPM package dependencies, by running:

$ npm install

Then obtain Titaniumifier and run the following command-line instruction to compose a Titanium module package:

$ titaniumifier

The above command yields a newly built ti-simple-xmpp-commonjs-*.zip file.

Example

var xmpp = require('ti-simple-xmpp').SimpleXMPP;

xmpp.on('online', function(data) {
    console.log('Connected with JID: ' + data.jid.user);
    console.log('Yes, I\'m connected!');
});

xmpp.on('chat', function(from, message) {
    xmpp.send(from, 'echo: ' + message);
});

xmpp.on('error', function(err) {
    console.error(err);
});

xmpp.on('subscribe', function(from) {
if (from === 'a.friend@gmail.com') {
    xmpp.acceptSubscription(from);
    }
});

xmpp.connect({
    websocket: { url: 'ws://myserver.com:5280/websocket/' },
    jid : 'username@myserver.com',
    password : 'password',
    reconnect: true,
    preferred: 'PLAIN',
    skipPresence: false
});

xmpp.subscribe('your.friend@gmail.com');
// check for incoming subscription requests
xmpp.getRoster();

Example app

There is a bare bones example app available that demonstrates some of this library's features.

Documentation

The API of this library is identical to Node Simple XMPP

License

Like the Simple XMPP package, this library is MIT licensed.

Known limitations

Currently, only XMPP over Websocket connections are supported. Ordinary XMPP connections establish TCP connections that require a replacement implementation for Node.js' net.Socket API in Titanium.

Acknowledgements

This package embeds a replacement XmlHttpRequest implementation (xhr.js) that is taken from XHR. The xhr.js file is MIT licensed.

About

Simple High Level Titanium XMPP Client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published