Note
The Node.js server only works on VPSes and Dedicated servers; it will not work on shared hosts!
Step One: Extraction and Upload
Go download the latest version of Ajax IM; the “Minified” copy should be fine for this guide. Once downloaded, extract the files to any folder on your computer.
After extraction, connect to your FTP server and create a new folder called ajaxim. Upload all of the Ajax IM files into this folder.
Step Two: Installation
Follow the installation guide. Be sure to select the “Node.js” or “Node.js (Guests)” server library. Once you’ve run the installer, move on to step three.
Step Three: Initialization
Great, you’ve installed Ajax IM! Now what?
Place the loading code in the header or footer of your website.
<script type="text/javascript" src="publicpathtoajaxim/js/im.load.js?node"></script>
Notes:
publicpathtoajaximshould be the publicly available path to your Ajax IM installation, e.g./ajaxim.- If you are using the “Guests” library instead of the regular Node.js library, replace
?nodewith?guest
Place this code on your website, either in the <head> section or before </body> (frequently in a header or footer file). It will automatically load any necessary libraries (jQuery, etc.) and the main Ajax IM script, im.js. Additionally, it will automatically initialize the Ajax IM class for you.
You can find out more about the individual initialization options by reading the im.js documentation.
Step Four: Allowing users to register and login
If you are using the “Guests” library, you can skip directly to step five. Users will automatically be logged in by the loading script.
Now that the IM library will automatically load on your website, you’ll need a way to allow users to login and register. Fortunately, Ajax IM provides a very simple function/widget that will handle this for you.
To insert a login/registration form, first add the code <div id="ajaxim"></div> somewhere on your site.
Below that <div> element, add the following code
<script type="text/javascript">
AjaxIM.loaded(function() { AjaxIM.client.form('#ajaxim'); });
</script>
This AjaxIM.client.form function will automatically load (from your theme) the login and registration forms, and insert them into the “ajaxim” element. This also means that you can insert this form into any element you would like; just swap “#ajaxim” for the element id you’d like to use (be sure to prefix it with ‘#’, which denotes that we’re referring to an element’s id).
Step Five: Running the Node.js server
First, please install the Node.js application.
Since installation should have automatically configured the Node.js server for you, all you need to do to run the Node.js server is navigate to the “server” folder and execute the following command on your command line:
node server.js
That’s all there is to it! If you would like to see debug messages (which will print data every time a user connects, disconnects, or executes an action), open server.js and set this.debug to true instead of false.
I am stuck on step 5. I used the defaults in the installation (Default node.js) and am on a shared host. I setup a page and loaded the necessary JavaScript but nothing loaded on the page. How do I get this “Node.js Server” running?