index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>What you will need: &mdash; Converse.js 0.3 documentation</title>
  7. <link rel="stylesheet" href="_static/stylesheet.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '',
  12. VERSION: '0.3',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/underscore.js"></script>
  20. <script type="text/javascript" src="_static/doctools.js"></script>
  21. <link rel="top" title="Converse.js 0.3 documentation" href="#" />
  22. </head>
  23. <body>
  24. <div id="header_wrap" class="outer">
  25. <header class="inner">
  26. <a id="forkme_banner" href="https://github.com/jcbrand/converse.js">View on GitHub</a>
  27. <h1 id="project_title"><a href="http://conversejs.org">Converse.js</a></h1>
  28. <h2 id="project_tagline">Documentation</h2>
  29. <section id="downloads">
  30. <a class="zip_download_link" href="https://github.com/jcbrand/converse.js/zipball/master">Download this project as a .zip file</a>
  31. <a class="tar_download_link" href="https://github.com/jcbrand/converse.js/tarball/master">Download this project as a tar.gz file</a>
  32. </section>
  33. </header>
  34. </div>
  35. <div id="main_content_wrap" class="outer">
  36. <div class="related">
  37. <h3>Navigation</h3>
  38. <ul>
  39. <li class="right" style="margin-right: 10px">
  40. <a href="genindex.html" title="General Index"
  41. accesskey="I">index</a></li>
  42. <li><a href="#">Converse.js 0.3 documentation</a> &raquo;</li>
  43. </ul>
  44. </div>
  45. <section id="main_content" class="inner">
  46. <div class="document">
  47. <div class="documentwrapper">
  48. <div class="body">
  49. <div class="toctree-wrapper compound">
  50. <ul class="simple">
  51. </ul>
  52. </div>
  53. <div class="contents local topic" id="table-of-contents">
  54. <p class="topic-title first">Table of Contents</p>
  55. <ul class="simple">
  56. <li><a class="reference internal" href="#what-you-will-need" id="id1">What you will need:</a><ul>
  57. <li><a class="reference internal" href="#an-xmpp-jabber-server" id="id2">An XMPP/Jabber server</a><ul>
  58. <li><a class="reference internal" href="#session-support-i-e-single-site-login" id="id3">Session support (i.e. single site login)</a></li>
  59. </ul>
  60. </li>
  61. <li><a class="reference internal" href="#connection-manager" id="id4">Connection Manager</a><ul>
  62. <li><a class="reference internal" href="#overcoming-cross-domain-request-restrictions" id="id5">Overcoming cross-domain request restrictions</a></li>
  63. </ul>
  64. </li>
  65. </ul>
  66. </li>
  67. <li><a class="reference internal" href="#converse-js-configuration-variables" id="id6">Converse.js Configuration variables:</a><ul>
  68. <li><a class="reference internal" href="#prebind" id="id7">prebind</a></li>
  69. <li><a class="reference internal" href="#fullname" id="id8">fullname</a></li>
  70. <li><a class="reference internal" href="#bosh-service-url" id="id9">bosh_service_url</a></li>
  71. <li><a class="reference internal" href="#xhr-user-search" id="id10">xhr_user_search</a></li>
  72. <li><a class="reference internal" href="#auto-subscribe" id="id11">auto_subscribe</a></li>
  73. <li><a class="reference internal" href="#auto-list-rooms" id="id12">auto_list_rooms</a></li>
  74. <li><a class="reference internal" href="#animate" id="id13">animate</a></li>
  75. </ul>
  76. </li>
  77. </ul>
  78. </div>
  79. <div class="section" id="what-you-will-need">
  80. <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>
  81. <div class="section" id="an-xmpp-jabber-server">
  82. <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>
  83. <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
  84. to connect to an XMPP/Jabber server (Jabber is really just a synonym for XMPP).</p>
  85. <p>You can either set up your own XMPP server, or use a public one. You can find a
  86. list of public XMPP servers/providers on <a class="reference external" href="http://xmpp.net">xmpp.net</a> and a list of servers that
  87. 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>
  88. <div class="section" id="session-support-i-e-single-site-login">
  89. <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>
  90. <p>It&#8217;s possible to enable single-site login, whereby users already
  91. authenticated in your website will also automatically be logged in on the chat server,
  92. but this will require custom code on your server.</p>
  93. <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>
  94. </div>
  95. </div>
  96. <div class="section" id="connection-manager">
  97. <h2><a class="toc-backref" href="#id4">Connection Manager</a><a class="headerlink" href="#connection-manager" title="Permalink to this headline">¶</a></h2>
  98. <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
  99. the webserver. HTTP connections are stateless and usually shortlived.</p>
  100. <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
  101. its connections are stateful and usually longer.</p>
  102. <p>To enable a web application like <em>Converse.js</em> to communicate with an XMPP
  103. server, we need a proxy in the middle that can act as a bridge between the two
  104. protocols.</p>
  105. <p>This is the job of a connection manager. A connection manager can be either a
  106. standalone application or part of an XMPP server. <a class="reference external" href="http://www.ejabberd.im">ejabberd</a> for example,
  107. includes a connection manager (but you have to enable it).</p>
  108. <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>.
  109. This connection manager is for testing purposes only, please don&#8217;t use it in
  110. production.</p>
  111. <div class="section" id="overcoming-cross-domain-request-restrictions">
  112. <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>
  113. <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>.
  114. HTTP requests are made by <em>Converse.js</em> to the connection manager via XmlHttpRequests (XHR).
  115. Until recently, it was not possible to make such requests to a different domain
  116. than the one currently being served (to prevent XSS attacks).</p>
  117. <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.
  118. Modern browsers support CORS, but there are problems with Internet Explorer &lt;
  119. 10.</p>
  120. <p>IE 8 and 9 partially support CORS via a proprietary implementation called
  121. 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
  122. support for XDomainRequest when it is present.</p>
  123. <p>In IE &lt; 8, there is no support for CORS.</p>
  124. <p>If you need to support these browsers, you can add a front-end proxy in
  125. Apache/Nginx which serves the connection manager under the same domain as your
  126. website. This will remove the need for any cross-domain XHR support.</p>
  127. </div>
  128. </div>
  129. </div>
  130. <div class="section" id="converse-js-configuration-variables">
  131. <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>
  132. <div class="section" id="prebind">
  133. <h2><a class="toc-backref" href="#id7">prebind</a><a class="headerlink" href="#prebind" title="Permalink to this headline">¶</a></h2>
  134. <p>Use this option when you want to attach to an existing XMPP connection that was
  135. already authenticated (usually on the backend before page load).</p>
  136. <p>This is useful when you don&#8217;t want to render the login form on the chat control
  137. box with each page load.</p>
  138. <p>When set to true, you&#8217;ll need to make sure that the onConnected method is
  139. called, and passed to it a Strophe connection object.</p>
  140. <p>Besides requiring the back-end to authenticate you, you&#8217;ll also
  141. have to write a Javascript snippet to attach to the set up connection:</p>
  142. <div class="highlight-python"><pre>$.JSON({
  143. 'url': 'mysite.com/xmpp-authenticate',
  144. 'success': function (data) {
  145. connection = new Strophe.Connection(bosh_service_url);
  146. connection.attach(data.jid, data.sid, data.rid, converse.onConnected);
  147. }</pre>
  148. </div>
  149. <p>The backend must authenticate for you, and then return a SID (session ID) and
  150. RID (Request ID), which you use when you attach to the connection.</p>
  151. </div>
  152. <div class="section" id="fullname">
  153. <h2><a class="toc-backref" href="#id8">fullname</a><a class="headerlink" href="#fullname" title="Permalink to this headline">¶</a></h2>
  154. <p>If you are using prebinding, you need to specify the fullname of the currently
  155. logged in user.</p>
  156. </div>
  157. <div class="section" id="bosh-service-url">
  158. <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>
  159. <p>Connections to an XMPP server depend on a BOSH connection manager which acts as
  160. a middle man between HTTP and XMPP.</p>
  161. <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>
  162. </div>
  163. <div class="section" id="xhr-user-search">
  164. <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>
  165. <p>There are two ways to add users.</p>
  166. <ul class="simple">
  167. <li>The user inputs a valid JID (Jabber ID), and the user is added as a pending</li>
  168. </ul>
  169. <p>contact.
  170. * 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>
  171. <p>This setting enables the second mechanism, otherwise by default the first will
  172. be used.</p>
  173. </div>
  174. <div class="section" id="auto-subscribe">
  175. <h2><a class="toc-backref" href="#id11">auto_subscribe</a><a class="headerlink" href="#auto-subscribe" title="Permalink to this headline">¶</a></h2>
  176. <p>If true, the user will automatically subscribe back to any contact requests.</p>
  177. </div>
  178. <div class="section" id="auto-list-rooms">
  179. <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>
  180. <p>If true, and the XMPP server on which the current user is logged in supports
  181. multi-user chat, then a list of rooms on that server will be fetched.</p>
  182. <p>Not recommended for servers with lots of chat rooms.</p>
  183. <p>For each room on the server a query is made to fetch further details (e.g.
  184. features, number of occupants etc.), so on servers with many rooms this
  185. option will create lots of extra connection traffic.</p>
  186. </div>
  187. <div class="section" id="animate">
  188. <h2><a class="toc-backref" href="#id13">animate</a><a class="headerlink" href="#animate" title="Permalink to this headline">¶</a></h2>
  189. <p>Show animations, for example when opening and closing chat boxes.</p>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. <div class="clearer"></div>
  195. </div>
  196. </section>
  197. <div class="related">
  198. <h3>Navigation</h3>
  199. <ul>
  200. <li class="right" style="margin-right: 10px">
  201. <a href="genindex.html" title="General Index"
  202. >index</a></li>
  203. <li><a href="#">Converse.js 0.3 documentation</a> &raquo;</li>
  204. </ul>
  205. </div>
  206. </div>
  207. <div id="footer_wrap" class="outer">
  208. <footer class="inner">
  209. &copy; Copyright 2013, JC Brand.
  210. <p class="copyright">Converse.js created by <a href="http://opkode.com" target="_blank">jcbrand</a></p>
  211. </footer>
  212. </div>
  213. </body>
  214. </html>