index.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. .. Converse.js documentation master file, created by
  2. sphinx-quickstart on Fri Apr 26 20:48:03 2013.
  3. You can adapt this file completely to your liking, but it should at least
  4. contain the root `toctree` directive.
  5. .. toctree::
  6. :maxdepth: 2
  7. .. contents:: Table of Contents
  8. :depth: 3
  9. :local:
  10. ===================
  11. What you will need:
  12. ===================
  13. An XMPP/Jabber server
  14. =====================
  15. *Converse.js* implements `XMPP`_ as its messaging protocol, and therefore needs
  16. to connect to an XMPP/Jabber server (Jabber is really just a synonym for XMPP).
  17. You can either set up your own XMPP server, or use a public one. You can find a
  18. list of public XMPP servers/providers on `xmpp.net`_ and a list of servers that
  19. you can set up yourself on `xmpp.org`_. Personally, I'm partial towards `ejabberd`_.
  20. Session support (i.e. single site login)
  21. ----------------------------------------
  22. It's possible to enable single-site login, whereby users already
  23. authenticated in your website will also automatically be logged in on the chat server,
  24. but this will require custom code on your server.
  25. Jack Moffitt has a great `blogpost`_ about this and even provides an `example Django application`_ to demonstrate it.
  26. Connection Manager
  27. ==================
  28. Your website and *Converse.js* use `HTTP`_ as protocol to communicate with
  29. the webserver. HTTP connections are stateless and usually shortlived.
  30. `XMPP`_ on the other hand, is the protocol that enables instant messaging, and
  31. its connections are stateful and usually longer.
  32. To enable a web application like *Converse.js* to communicate with an XMPP
  33. server, we need a proxy in the middle that can act as a bridge between the two
  34. protocols.
  35. This is the job of a connection manager. A connection manager can be either a
  36. standalone application or part of an XMPP server. `ejabberd`_ for example,
  37. includes a connection manager (but you have to enable it).
  38. The demo on the `Converse.js homepage`_ uses a a connection manager located at https://bind.opkode.im.
  39. This connection manager is for testing purposes only, please don't use it in
  40. production.
  41. Overcoming cross-domain request restrictions
  42. --------------------------------------------
  43. The domain of the *Converse.js* demo is *conversejs.org*, but the domain of the connection manager is *opkode.im*.
  44. HTTP requests are made by *Converse.js* to the connection manager via XmlHttpRequests (XHR).
  45. Until recently, it was not possible to make such requests to a different domain
  46. than the one currently being served (to prevent XSS attacks).
  47. Luckily there is now a standard called `CORS`_ (Cross-origin resource sharing), which enables exactly that.
  48. Modern browsers support CORS, but there are problems with Internet Explorer <
  49. 10.
  50. IE 8 and 9 partially support CORS via a proprietary implementation called
  51. XDomainRequest. There is a `Strophe.js plugin`_ which you can use to enable
  52. support for XDomainRequest when it is present.
  53. In IE < 8, there is no support for CORS.
  54. If you need to support these browsers, you can add a front-end proxy in
  55. Apache/Nginx which serves the connection manager under the same domain as your
  56. website. This will remove the need for any cross-domain XHR support.
  57. ====================================
  58. Converse.js Configuration variables:
  59. ====================================
  60. prebind
  61. ========
  62. Use this option when you want to attach to an existing XMPP connection that was
  63. already authenticated (usually on the backend before page load).
  64. This is useful when you don't want to render the login form on the chat control
  65. box with each page load.
  66. When set to true, you'll need to make sure that the onConnected method is
  67. called, and passed to it a Strophe connection object.
  68. Besides requiring the back-end to authenticate you, you'll also
  69. have to write a Javascript snippet to attach to the set up connection::
  70. $.JSON({
  71. 'url': 'mysite.com/xmpp-authenticate',
  72. 'success': function (data) {
  73. connection = new Strophe.Connection(bosh_service_url);
  74. connection.attach(data.jid, data.sid, data.rid, converse.onConnected);
  75. }
  76. The backend must authenticate for you, and then return a SID (session ID) and
  77. RID (Request ID), which you use when you attach to the connection.
  78. fullname
  79. ========
  80. If you are using prebinding, you need to specify the fullname of the currently
  81. logged in user.
  82. bosh_service_url
  83. ================
  84. Connections to an XMPP server depend on a BOSH connection manager which acts as
  85. a middle man between HTTP and XMPP.
  86. See `here`_ for more information.
  87. xhr_user_search
  88. ===============
  89. There are two ways to add users.
  90. * The user inputs a valid JID (Jabber ID), and the user is added as a pending
  91. contact.
  92. * 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.
  93. This setting enables the second mechanism, otherwise by default the first will
  94. be used.
  95. auto_subscribe
  96. ==============
  97. If true, the user will automatically subscribe back to any contact requests.
  98. auto_list_rooms
  99. ===============
  100. If true, and the XMPP server on which the current user is logged in supports
  101. multi-user chat, then a list of rooms on that server will be fetched.
  102. Not recommended for servers with lots of chat rooms.
  103. For each room on the server a query is made to fetch further details (e.g.
  104. features, number of occupants etc.), so on servers with many rooms this
  105. option will create lots of extra connection traffic.
  106. animate
  107. =======
  108. Show animations, for example when opening and closing chat boxes.
  109. .. _`here`: http://metajack.im/2008/09/08/which-bosh-server-do-you-need/l
  110. .. _`HTTP`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
  111. .. _`XMPP`: https://en.wikipedia.org/wiki/Xmpp
  112. .. _`Converse.js homepage`: http://conversejs.org
  113. .. _`CORS`: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
  114. .. _`Strophe.js plugin`: https://gist.github.com/1095825/6b4517276f26b66b01fa97b0a78c01275fdc6ff2
  115. .. _`xmpp.net`: http://xmpp.net
  116. .. _`xmpp.org`: http://xmpp.org/xmpp-software/servers/
  117. .. _`ejabberd`: http://www.ejabberd.im
  118. .. _`blogpost`: http://metajack.im/2008/10/03/getting-attached-to-strophe
  119. .. _`example Django application`: https://github.com/metajack/strophejs/tree/master/examples/attach