Permalink
Browse files

add strophe demo

git-svn-id: https://svn.rad0.net/repos/rad/xmpp/strophejs-pubsub-demo@22990 4f02d5a8-cb4b-4bb5-80e5-e6ac929fdd9a
  • Loading branch information...
whomwah committed Nov 23, 2010
0 parents commit 1f3bf21693701d2f0e11175e07d36b215b300b68
Showing with 704 additions and 0 deletions.
  1. +45 −0 README.md
  2. +26 −0 client.html
  3. +120 −0 css/styles.css
  4. +181 −0 docs/install_ejabberd.centos.5.5.x86_64.txt
  5. +130 −0 js/client.js
  6. +136 −0 js/publisher.js
  7. +13 −0 js/shared.js
  8. +1 −0 js/strophe.min.js
  9. +1 −0 js/strophe.pubsub.min.js
  10. +51 −0 publisher.html
@@ -0,0 +1,45 @@
+XMPP/HTTP PubSub Demo
+=====================
+
+A simple demo of Publish/Subscribe in the browser using Strophe.js
+
+This consists of a client.html and a publisher.html and a working
+XMPP setup (see below). Once you have added the configuration
+details for your setup, you should be able to go to the
+publisher.html and send HTML and txt messages. Any number of
+people who have connected to client.html will recieved these
+messages and display them on their screen.
+
+Browser Support
+---------------
+
+You need a modern browser. This code has been tested in:
+
+* Google Chrome
+* Safari 4+
+* Firefox 3.5+
+
+If you find it works in any other browsers, do let us know.
+
+Strophe
+-------
+
+This demo uses the wonderful Strophe.js to do all the clever stuff.
+
+(strophe.js)[https://github.com/metajack/strophejs]
+(strophe.pubsub.js)[https://github.com/metajack/strophejs]
+
+minimized versions of both are included, but for the latest versions
+and more information, visit the links above.
+
+Setup
+-----
+
+You also need a running XMPP server and BOSH connection manager. (Ejabberd)[http://www.ejabberd.im/]
+is a popular XMPP server and latest versions comes with BOSH support
+baked in and enabled by default.
+
+I have added installation instructions for Ejabberd on Centos 5.5 in
+the /docs directory. If you have similar instructions for other setups
+please send pull requests, and I'll try and feed these back.
+
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html dir="ltr" lang="en" xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>XMPP Pubsub Demo :: Client</title>
+ <meta charset=utf-8 />
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script type="text/javascript" src="js/strophe.min.js"></script>
+ <script type="text/javascript" src="js/strophe.pubsub.min.js"></script>
+ <script type="text/javascript" src="js/shared.js"></script>
+ <script type="text/javascript" src="js/client.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Serif&amp;subset=latin" />
+ <link rel="stylesheet" href="css/styles.css" media="screen" />
+</head>
+<body>
+<div id="wrapper">
+ <div id="connection_status">Connecting...</div>
+ <div id="content">
+ <div>
+ <h1>XMPP PubSub Demo</h1>
+ <p>Any message you get sent will appear below:</p>
+ <p id="message"></p>
+ </div>
+ </div>
+</div>
+</body>
+</html>
@@ -0,0 +1,120 @@
+html, body, h1, form, fieldset, legend, ol, li {
+ margin: 0;
+ padding: 0;
+}
+
+h1 {
+ font-size:1.4em;
+}
+
+#connection_status {
+ margin-bottom:10px;
+}
+
+body {
+ background: #fff;
+ color: #111111;
+ font: 120% "Droid Serif", Georgia, "Times New Roman", Times, serif;
+ padding: 20px;
+}
+
+form {
+ background: #ccc;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ padding: 20px;
+ width: 500px;
+}
+
+form fieldset {
+ border: none;
+ margin-bottom: 15px;
+}
+
+form fieldset:last-of-type {
+ margin-bottom: 0;
+}
+
+form li {
+ background: #b9cf6a;
+ background: rgba(255,255,255,.3);
+ border-color: #e3ebc3;
+ border-color: rgba(255,255,255,.6);
+ border-style: solid;
+ border-width: 2px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ line-height: 30px;
+ list-style: none;
+ padding: 5px 10px;
+ margin-bottom: 5px;
+}
+
+form fieldset fieldset label {
+ line-height: 20px;
+ padding: 0 0 0 20px;
+ font-weight:normal;
+ width: auto;
+}
+
+form ul li {
+ background: none;
+ border: none;
+ float: left;
+}
+
+form input[type=radio] {
+ float: left;
+ margin-right: 5px;
+}
+
+
+form legend,
+form label {
+ font-size: 13px;
+ font-weight:bold;
+ display:block;
+}
+
+
+form textarea {
+ background: #fff;
+ border: none;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ border-radius: 3px;
+ outline: none;
+ padding: 10px;
+ width: 460px;
+ height: 120px;
+ font-size:14px;
+}
+
+form button {
+ background: #666;
+ border: none;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ -khtml-border-radius: 10px;
+ border-radius: 10px;
+ color: #ffffff;
+ display: block;
+ margin: auto;
+ padding: 7px 25px;
+ text-shadow: 0 1px 1px #000000;
+ text-transform: uppercase;
+ font-size:16px;
+ cursor:pointer;
+}
+
+form button:hover {
+ background: #333;
+ border: none;
+}
+
+.red { color:red; }
+.blue { color:blue; }
+.green { color:green; }
@@ -0,0 +1,181 @@
+Installing Ejabberd on Centos 5.5 ready for PubSub over BOSH
+==================================================================
+
+These instructions should help you install Ejabberd, as well as
+getting you up and running for XMPP over HTTP via the BOSH interface.
+
+
+Download
+--------
+
+You can download the latest version from:
+http://www.process-one.net/en/ejabberd/downloads
+
+From the dropdown choose one of the Linux Installers rather than source.
+It's just easier. You'll need to choose which architecture.
+You can check by running:
+
+$ uname -m
+
+on the machine you are installing it on. If you see x86_64 then you will
+need to choose the 64bit version, otherwise choose the 32bit.
+
+Copy this file to /opt on your destination machine.
+
+NOTE:
+The rest of these instruction will assume you are installing version 2.1.5
+on a 64bit machine for the domain vm.local. If you are installing a
+different version then just swap the numbers.
+
+
+Unpack
+------
+
+Naviagate to the installer on your destnation machine. Unpack with:
+
+$ gunzip ejabberd-2.1.5-linux-x86_64-installer.bin.gz
+
+--
+
+Now make the installer executable
+
+$ chmod +x ejabberd-2.1.5-linux-x86_64-installer.bin
+
+
+Installation
+------------
+
+You can now run the installer. You'll need to choose a language and
+accept the license.
+
+Next you be asked where to install. I would install in /opt so you
+would fill this in with:
+
+/opt/ejabberd-2.1.5
+
+--
+
+Next you will be asked to set a desired domain name. This needs to be
+a domain name that the computer you are installing this on is known as on
+your network. If you are installing ejabberd locally or on a virtual
+machine you could give it a name like vm.local and adjust you hosts file
+to suit.
+
+--
+
+Next create the admin user. Try and change the username to something other
+than admin. This is the superuser that has full admin control of your installation.
+
+e.g nimda
+
+--
+
+Next you create a password for the admin user
+
+e.g a1b2c3
+
+--
+
+Answer NO to whether this machine is part of a cluster. Mark it as something to
+learn about afterwards.
+
+--
+
+That should be it, and you will be asked if you would like to continue and
+actually install Ejabberd. Choose Yes.
+
+--
+
+Once this finshes you should have Ejabberd installed in /opt. You can now remove
+the installer ejabberd-2.1.5-linux-x86_64-installer.bin
+
+
+Starting Ejabberd
+-----------------
+
+I find the easiest way to manage the starting and stopping of Ejabberd is via a
+init.d script. Create a file in /etc/init.d/ called ejabberd the copy and paste this
+code into it:
+
+https://gist.github.com/710135
+
+Remembering to change line 13 to point to your installed version.
+
+--
+
+Next you need to make
+that file executable and add it to the other programs started on bootup:
+
+$ chmod +x /etc/init.d/ejabberd
+$ /sbin/chkconfig --add ejabberd
+
+You can check this with:
+
+$ /sbin/chkconfig --list ejabberd
+ejabberd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
+
+--
+
+Now we create a user to run it under and change the permission of our install.
+We'll use the user as we have in our init.d script:
+
+// NOTE: we're creating home directly too, so the .erlang.cookie has a home. I'm
+// sure there are lots of variations here, but this one works.
+$ /usr/sbin/adduser ejabberd
+$ chown -R ejabberd:ejabberd ejabberd-2.1.5/
+
+--
+
+The BOSH interface which allows us to talk XMPP over HTTP is available via
+port 5280, along with the admin interface. We need to make this available by
+updating the iptables. Load up /etc/sysconfig/iptables in your favourite
+editor and add the line:
+
+-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5280 -j ACCEPT
+
+You probably see a similar line where 5280 is replaced with 22. You can add the line
+below that one. To make this change take effect, you'll need to run:
+
+$ /sbin/service/iptables restart
+
+--
+
+Finally, in order to have a PubSub system that anyone can use, we need to
+enable anonomous login, otherwise we would have to create an account for
+every client that wanted to connect. To enable this you need to edit the
+config file:
+
+/opt/ejabberd-2.1.5/conf/ejabberd.cfg
+
+Just after the AUTHENTICATION section (line 250) add this line
+
+{host_config, "vm.local", [{auth_method, [anonymous]},
+ {anonymous_protocol, both}]}.
+
+You'll then need to restart Ejabberd:
+
+$ /sbin/service ejabberd restart
+
+--
+
+Hurrah!, all installed and ready to go. You should now be able to log into to the ejabberd
+admin interface at:
+
+http://vm.local:5280/admin
+
+and you will be asked for a username and password. This seems to always trip people
+up, and they put in the wrong username. To log in as administrator, based on the
+information we have used above, it would be:
+
+username: nimda@vm.local
+password: a1b2c3
+
+--
+
+So, now you have a working XMPP server. Please note, that what I've explained is enough
+to get you going. I can't guarentee that this is a bullet proof secure setup, it's just
+a snippet of what's possible. If you want know more, I suggest you visit:
+
+http://www.ejabberd.im/
+
+
Oops, something went wrong.

0 comments on commit 1f3bf21

Please sign in to comment.