Documentation.

Server Libraries PHP-only (Default)

Sections

Basics

  1. Quick Start Guide
  2. Quick Start with Node.js
  3. Theming

Development

  1. Server Libraries
  2. Database Backends

Code API

  1. Server-side PHP
  2. Node.js Server
  3. Client-Side Scripts
 

Overview

The PHP-only library allows you to run Ajax IM on a shared server, where you don’t usu­ally have the abil­ity to run other servers or appli­ca­tions. Despite being pure PHP, it allows for all three types of AJAX: short polling, long polling, and stream­ing; the lat­ter two are con­sid­ered forms of Comet. The script requires that a data­base library (such as the included MySQL library) be in use in order to han­dle authen­ti­ca­tion and sending/receiving messages.

This library is database-agnostic, mean­ing that it should work with any properly-constructed data­base library.

If at all pos­si­ble, it is rec­om­mended that you use the Node.js server. This PHP-only class is only included for com­pat­i­bil­ity and convenience.

poll($method) Function

The poll($method) func­tion is where all the “action” hap­pens after authen­ti­ca­tion. The method of polling used by Ajax IM is defined when you ini­tial­ize your AjaxIM object on the client side. This func­tion is called auto­mat­i­cally by the server script, server.php. As pre­vi­ously men­tioned, you have three options for polling method:

  • short polling — The server checks for any mes­sages, and returns imme­di­ately, whether or not it has found any data.
  • long polling — The server checks for mes­sages, and con­tin­ues check­ing every few sec­onds for up to 30 sec­onds or until data is found (whichever comes first). Upon find­ing data, it is sent and the con­nec­tion is closed (and the process repeats). Note: The 30 sec­ond time­out has been imple­mented to try and reduce server strain.
  • comet (stream­ing) — The server checks for mes­sages and keeps the con­nec­tion open indef­i­nitely. As new data arrives, it is pushed to the client via <script> tags.

No Comments Yet

You can be the first to comment!

Leave a comment