README.markdown

Wed, 10 Feb 2010 14:50:48 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 10 Feb 2010 14:50:48 +0000
changeset 10
543c2018896c
child 11
080d81e07112
permissions
-rw-r--r--

Add README.markdown

10
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 # xmpp.js
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 ## Server-side XMPP in Javascript
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 [xmpp.js](http://xmppjs.prosody.im/) is a library for [Node.js](http://nodejs.org/) that allows
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 you to connect to an XMPP server as a component.
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 For those already familiar with the client-side [Strophe.js](http://code.stanziq.com/strophe/)
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 library then there is almost nothing to learn - the API is almost exactly the same. The only
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 difference is that this time you can run your code on the server, and handle XMPP traffic from
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 clients on behalf of a whole domain. It's like writing an XMPP server but with the hard parts
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 handled for you.
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 xmpp.js works with any [XEP-0114](http://www.xmpp.org/extensions/xep-0114.html)-compliant server
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 (that's practically all of them), so you need not worry about your code being tied in to a
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 particular server implementation.
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 ### How it works at the XMPP level
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 XMPP components "bind" to a domain, usually a subdomain of the main XMPP service, such as
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 pubsub.example.org, or conference.example.org. All incoming stanzas addressed to that domain
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 (to='service.example.org') or to entities on that domain (to='user@service.example.org') will be
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 routed to your xmpp.js-based code.
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 For outgoing stanzas your component is in full control. You can specify any 'from' address on
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 your stanzas, many servers don't even enforce that the originating domain of the stanza is the
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 component's domain, allowing you to send stanzas on behalf of any user on the server.
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 ### Getting started
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 Firstly, you'll need Node installed if you haven't it already, this is fairly straightforward -
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 *[instructions are here](#)*.
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 Check out the source xmpp.js code, from either the *Mercurial repository* or *Github project*.
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 In the examples directory you will find an example component which echoes messages it receives
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 back to the sender. If you have a local [Prosody](http://prosody.im/) server installed then you
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 can simply add these lines to your Prosody config to make this example work:
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 Component "echo.localhost"
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 component_secret = "hellohello"
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 Ater restarting Prosody try running:
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 node examples/echo.js
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 Log into your Prosody with a client and send a message to anything@echo.localhost - you should
543c2018896c Add README.markdown
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 receive an instant response back - congratulations!

mercurial