xmpp.chapril.org-conversejs/docs/html/index.html

229 lines
13 KiB
HTML
Raw Normal View History

2013-04-26 21:01:39 +02:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>What you will need: &mdash; Converse.js 0.3 documentation</title>
2013-04-26 21:01:39 +02:00
<link rel="stylesheet" href="_static/stylesheet.css" type="text/css" />
2013-04-26 21:01:39 +02:00
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Converse.js 0.3 documentation" href="#" />
</head>
<body>
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/jcbrand/converse.js">View on GitHub</a>
<h1 id="project_title"><a href="http://conversejs.org">Converse.js</a></h1>
<h2 id="project_tagline">Documentation</h2>
<section id="downloads">
<a class="zip_download_link" href="https://github.com/jcbrand/converse.js/zipball/master">Download this project as a .zip file</a>
<a class="tar_download_link" href="https://github.com/jcbrand/converse.js/tarball/master">Download this project as a tar.gz file</a>
</section>
</header>
</div>
<div id="main_content_wrap" class="outer">
2013-04-26 21:01:39 +02:00
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li><a href="#">Converse.js 0.3 documentation</a> &raquo;</li>
</ul>
</div>
<section id="main_content" class="inner">
2013-04-26 21:01:39 +02:00
<div class="document">
<div class="documentwrapper">
<div class="body">
<div class="toctree-wrapper compound">
2013-04-26 21:01:39 +02:00
<ul class="simple">
</ul>
</div>
<div class="contents local topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#what-you-will-need" id="id1">What you will need:</a><ul>
<li><a class="reference internal" href="#an-xmpp-jabber-server" id="id2">An XMPP/Jabber server</a><ul>
<li><a class="reference internal" href="#session-support-i-e-single-site-login" id="id3">Session support (i.e. single site login)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#connection-manager" id="id4">Connection Manager</a><ul>
<li><a class="reference internal" href="#overcoming-cross-domain-request-restrictions" id="id5">Overcoming cross-domain request restrictions</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#converse-js-configuration-variables" id="id6">Converse.js Configuration variables:</a><ul>
<li><a class="reference internal" href="#prebind" id="id7">prebind</a></li>
<li><a class="reference internal" href="#fullname" id="id8">fullname</a></li>
<li><a class="reference internal" href="#bosh-service-url" id="id9">bosh_service_url</a></li>
<li><a class="reference internal" href="#xhr-user-search" id="id10">xhr_user_search</a></li>
<li><a class="reference internal" href="#auto-subscribe" id="id11">auto_subscribe</a></li>
<li><a class="reference internal" href="#auto-list-rooms" id="id12">auto_list_rooms</a></li>
<li><a class="reference internal" href="#animate" id="id13">animate</a></li>
2013-04-26 21:01:39 +02:00
</ul>
</li>
</ul>
</div>
<div class="section" id="what-you-will-need">
<h1><a class="toc-backref" href="#id1">What you will need:</a><a class="headerlink" href="#what-you-will-need" title="Permalink to this headline"></a></h1>
<div class="section" id="an-xmpp-jabber-server">
<h2><a class="toc-backref" href="#id2">An XMPP/Jabber server</a><a class="headerlink" href="#an-xmpp-jabber-server" title="Permalink to this headline"></a></h2>
<p><em>Converse.js</em> implements <a class="reference external" href="https://en.wikipedia.org/wiki/Xmpp">XMPP</a> as its messaging protocol, and therefore needs
to connect to an XMPP/Jabber server (Jabber is really just a synonym for XMPP).</p>
<p>You can either set up your own XMPP server, or use a public one. You can find a
list of public XMPP servers/providers on <a class="reference external" href="http://xmpp.net">xmpp.net</a> and a list of servers that
you can set up yourself on <a class="reference external" href="http://xmpp.org/xmpp-software/servers/">xmpp.org</a>. Personally, I&#8217;m partial towards <a class="reference external" href="http://www.ejabberd.im">ejabberd</a>.</p>
<div class="section" id="session-support-i-e-single-site-login">
<h3><a class="toc-backref" href="#id3">Session support (i.e. single site login)</a><a class="headerlink" href="#session-support-i-e-single-site-login" title="Permalink to this headline"></a></h3>
<p>It&#8217;s possible to enable single-site login, whereby users already
authenticated in your website will also automatically be logged in on the chat server,
but this will require custom code on your server.</p>
<p>Jack Moffitt has a great <a class="reference external" href="http://metajack.im/2008/10/03/getting-attached-to-strophe">blogpost</a> about this and even provides an <a class="reference external" href="https://github.com/metajack/strophejs/tree/master/examples/attach">example Django application</a> to demonstrate it.</p>
</div>
</div>
<div class="section" id="connection-manager">
<h2><a class="toc-backref" href="#id4">Connection Manager</a><a class="headerlink" href="#connection-manager" title="Permalink to this headline"></a></h2>
<p>Your website and <em>Converse.js</em> use <a class="reference external" href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a> as protocol to communicate with
the webserver. HTTP connections are stateless and usually shortlived.</p>
<p><a class="reference external" href="https://en.wikipedia.org/wiki/Xmpp">XMPP</a> on the other hand, is the protocol that enables instant messaging, and
its connections are stateful and usually longer.</p>
<p>To enable a web application like <em>Converse.js</em> to communicate with an XMPP
server, we need a proxy in the middle that can act as a bridge between the two
protocols.</p>
<p>This is the job of a connection manager. A connection manager can be either a
standalone application or part of an XMPP server. <a class="reference external" href="http://www.ejabberd.im">ejabberd</a> for example,
includes a connection manager (but you have to enable it).</p>
<p>The demo on the <a class="reference external" href="http://conversejs.org">Converse.js homepage</a> uses a a connection manager located at <a class="reference external" href="https://bind.opkode.im">https://bind.opkode.im</a>.
This connection manager is for testing purposes only, please don&#8217;t use it in
production.</p>
<div class="section" id="overcoming-cross-domain-request-restrictions">
<h3><a class="toc-backref" href="#id5">Overcoming cross-domain request restrictions</a><a class="headerlink" href="#overcoming-cross-domain-request-restrictions" title="Permalink to this headline"></a></h3>
<p>The domain of the <em>Converse.js</em> demo is <em>conversejs.org</em>, but the domain of the connection manager is <em>opkode.im</em>.
HTTP requests are made by <em>Converse.js</em> to the connection manager via XmlHttpRequests (XHR).
Until recently, it was not possible to make such requests to a different domain
than the one currently being served (to prevent XSS attacks).</p>
<p>Luckily there is now a standard called <a class="reference external" href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS</a> (Cross-origin resource sharing), which enables exactly that.
Modern browsers support CORS, but there are problems with Internet Explorer &lt;
10.</p>
<p>IE 8 and 9 partially support CORS via a proprietary implementation called
XDomainRequest. There is a <a class="reference external" href="https://gist.github.com/1095825/6b4517276f26b66b01fa97b0a78c01275fdc6ff2">Strophe.js plugin</a> which you can use to enable
support for XDomainRequest when it is present.</p>
<p>In IE &lt; 8, there is no support for CORS.</p>
<p>If you need to support these browsers, you can add a front-end proxy in
Apache/Nginx which serves the connection manager under the same domain as your
website. This will remove the need for any cross-domain XHR support.</p>
</div>
</div>
</div>
<div class="section" id="converse-js-configuration-variables">
<h1><a class="toc-backref" href="#id6">Converse.js Configuration variables:</a><a class="headerlink" href="#converse-js-configuration-variables" title="Permalink to this headline"></a></h1>
2013-04-26 21:01:39 +02:00
<div class="section" id="prebind">
<h2><a class="toc-backref" href="#id7">prebind</a><a class="headerlink" href="#prebind" title="Permalink to this headline"></a></h2>
2013-04-26 21:01:39 +02:00
<p>Use this option when you want to attach to an existing XMPP connection that was
already authenticated (usually on the backend before page load).</p>
<p>This is useful when you don&#8217;t want to render the login form on the chat control
box with each page load.</p>
<p>When set to true, you&#8217;ll need to make sure that the onConnected method is
called, and passed to it a Strophe connection object.</p>
<p>Besides requiring the back-end to authenticate you, you&#8217;ll also
have to write a Javascript snippet to attach to the set up connection:</p>
<div class="highlight-python"><pre>$.JSON({
'url': 'mysite.com/xmpp-authenticate',
'success': function (data) {
connection = new Strophe.Connection(bosh_service_url);
connection.attach(data.jid, data.sid, data.rid, converse.onConnected);
}</pre>
</div>
<p>The backend must authenticate for you, and then return a SID (session ID) and
RID (Request ID), which you use when you attach to the connection.</p>
</div>
<div class="section" id="fullname">
<h2><a class="toc-backref" href="#id8">fullname</a><a class="headerlink" href="#fullname" title="Permalink to this headline"></a></h2>
2013-04-26 21:01:39 +02:00
<p>If you are using prebinding, you need to specify the fullname of the currently
logged in user.</p>
</div>
<div class="section" id="bosh-service-url">
<h2><a class="toc-backref" href="#id9">bosh_service_url</a><a class="headerlink" href="#bosh-service-url" title="Permalink to this headline"></a></h2>
2013-04-26 21:01:39 +02:00
<p>Connections to an XMPP server depend on a BOSH connection manager which acts as
a middle man between HTTP and XMPP.</p>
<p>See <a class="reference external" href="http://metajack.im/2008/09/08/which-bosh-server-do-you-need/l">here</a> for more information.</p>
</div>
<div class="section" id="xhr-user-search">
<h2><a class="toc-backref" href="#id10">xhr_user_search</a><a class="headerlink" href="#xhr-user-search" title="Permalink to this headline"></a></h2>
2013-04-26 21:01:39 +02:00
<p>There are two ways to add users.</p>
<ul class="simple">
<li>The user inputs a valid JID (Jabber ID), and the user is added as a pending</li>
</ul>
<p>contact.
* The user inputs some text (for example part of a firstname or lastname), an XHR will be made to a backend, and a list of matches are returned. The user can then choose one of the matches to add as a contact.</p>
<p>This setting enables the second mechanism, otherwise by default the first will
be used.</p>
</div>
<div class="section" id="auto-subscribe">
<h2><a class="toc-backref" href="#id11">auto_subscribe</a><a class="headerlink" href="#auto-subscribe" title="Permalink to this headline"></a></h2>
2013-04-26 21:01:39 +02:00
<p>If true, the user will automatically subscribe back to any contact requests.</p>
</div>
<div class="section" id="auto-list-rooms">
<h2><a class="toc-backref" href="#id12">auto_list_rooms</a><a class="headerlink" href="#auto-list-rooms" title="Permalink to this headline"></a></h2>
<p>If true, and the XMPP server on which the current user is logged in supports
multi-user chat, then a list of rooms on that server will be fetched.</p>
<p>Not recommended for servers with lots of chat rooms.</p>
<p>For each room on the server a query is made to fetch further details (e.g.
features, number of occupants etc.), so on servers with many rooms this
option will create lots of extra connection traffic.</p>
</div>
2013-04-26 21:01:39 +02:00
<div class="section" id="animate">
<h2><a class="toc-backref" href="#id13">animate</a><a class="headerlink" href="#animate" title="Permalink to this headline"></a></h2>
2013-04-26 21:01:39 +02:00
<p>Show animations, for example when opening and closing chat boxes.</p>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</section>
2013-04-26 21:01:39 +02:00
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li><a href="#">Converse.js 0.3 documentation</a> &raquo;</li>
</ul>
</div>
</div>
<div id="footer_wrap" class="outer">
<footer class="inner">
2013-04-26 21:01:39 +02:00
&copy; Copyright 2013, JC Brand.
<p class="copyright">Converse.js created by <a href="http://opkode.com" target="_blank">jcbrand</a></p>
</footer>
2013-04-26 21:01:39 +02:00
</div>
</body>
</html>