sstrigler / JSJaC

JavaScript Jabber Client Library
Other
295 stars 86 forks source link

JSJaC - JavaScript Jabber Client Library

JSJaC is an XMPP (formerly known as Jabber) client library written in JavaScript to ease implementation of web based XMPP clients. For communication with an XMPP server it needs to support either HTTP Polling or XMPP Over BOSH (formerly known as HTTP Binding) or XMPP Over WebSocket. JSJaC has an object oriented interface which should be quite easy to use. Communication is done by using the HTTPRequest object (also refered to as AJAX technology) or WebSocket. Your browser must support this. JSJaC is fully compatible with all major JavaScript frameworks.

Note: As security restrictions of most modern browsers prevent HTTP Polling from being usable anymore this module is disabled by default now. If you want to compile it in use 'make polling'.

License

JSJaC is licensed under the terms of the Mozilla Public License version 1.1 or, at your option, under the terms of the GNU General Public License version 2 or subsequent, or the terms of the GNU Lesser General Public License version 2.1 or subsequent.

The complete text of each of these license can be found in the same directory as this file. See

Build

In order to build a single compressed file to be included from within your app please run make at the top level directory of this project.

Hints on Usage

Service Address

Let's say your JSJaC based web application is located at http://example.com/. Your XMPP server is at jabber-example.com and it's HTTP Binding service is located at http://jabber-example.org:5280/ or https://jabber-example.org:5281/.

    <VirtualHost *>
      Servername example.com
      DocumentRoot /var/www
      AddDefaultCharset UTF-8
      RewriteEngine On
      RewriteRule ^/http-bind/ http://jabber-example.com:5280/http-bind/ [P]
    </VirtualHost>

With this you'd end up having access to the Jabber server's service at http://example.com/http-bind/ (the httpbase address).

    var oDbg = new JSJaCConsoleLogger(3);

    var connector = new JSJaCHttpBindingConnection({
        oDbg: oDbg,
        httpbase: 'http://jabber-example.org:5280/http-bind/',
        timerval: 500
    });

More information: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

Debug Logger

JSJaCConnection supports use of JSDebugger which is available separately.

JSJaC also ships with a class JSJaCConsoleLogger which lets you log to Firebug's and Safari's console.

Example

For an example on how to use this library within your web application please have to look at examples/simpleclient.html or examples/simpleCrossDomainClient.html.

Supported Browsers and Platforms

The following browsers are known to work with HTTP Binding. Let me know about others!

The following browsers are known to work with cross domain requests.

The following browsers are known to work with WebSocket.

Documentation

Documentation is provided by JSDoc under the docs/ subdirectory if you've downloaded JSJaC as a tarball. Otherwise you can generate it on your own by make doc.

There's also an online version available at http://sstrigler.github.com/JSJaC/.