'Chat' Template Overview

Site Map
Application Guide
Contact Whitebeam
Whitebeam Users

'Chat' Template Overview


The chat template provides all the building blocks required to build an interactive chat room.

A chat room is an area on a Web site that provides a place for users to communicate in real time. This is distinct from forums and discussion forums where users post messages, but and have to return, or refresh pages to see responses.

The Whitebeam 'chat' template provides the core server-side functionality to support various client-side technologies. The intended use is to provide a framework whereby the only thing required by a client is JavaScript and HTML. This does not preclude the use of other technologies such as client-side Java applets if so desired by the application writer.

The chat template provides the following basic services :

  • Support for multiple chat-rooms per web-site (application)
  • Option to archive chat-room discussions to provide a subsequent transcription.
  • Support for application defined user flags. This allows an application to implement different roles for different members - for example moderator, listenner, contributor
  • Support for 'member' rooms and 'guest' rooms
  • List of users currently in each room
  • Option to link with the contact template to control access to individual rooms. This allows different classes of room within a single site - for example : public discussion, member discussion and private 'organisers' discussion

Building a chat application

The chat template provides all the basic functionality required to build a chat room application within your web-site. What remains is to interface that to the browser.

There are many ways to do this. Here we assume the client-side part of the application is written in client-side JavaScript. Whitebeam application pages provide the server side bridge between the client-side script and the chat template.

The main functions required from an application are:

  1. Create chat rooms. Rooms must be created before they are used!
  2. Present users with a list of available rooms
  3. User enters a room. That users browser will then periodically poll the Whitebeam server for new messages. The poll is achieved using client-side JavaScript and the HTTP requests (eg using AJAX techniques)

The chat template provides most of the low-level functionality required to build a chat application. Most of the rest of the work involves writing the client-side JavaScript stores chat room information in the Postgres database. The first step to creat

Chat template architecture

Implementing chat-room functionality poses a number of challenges to traditional server-side architectures. Each 'user' within a room needs to rapidly determine when new messages are added to their room in order to meet the interactive real-time expectations of chat. There are two common approaches :

  1. Polled - whereby each client browser periodically makes an HTTP request to the server requesting any new messages
  2. Open connection - whereby each client holds open a connection to the server and the server then 'pushes' messages out to each client when available.

In the first case the server must be able to deal with multiple poll requests quickly and efficiently. In the second there can be significant overhead in maintaining multiple open connections to the server. For example with 50 people in rooms, using a technology like PHP would required 50 Apache processes being tied up servicing chat clients that may not be doing anything!

The Whitebeam web-services template model provides a very high capacity, high performance means of implementing a polled chat room architecture.

©YellowHawk Ltd 2006-2007 : Whitebeam release 1.3.36
(loadtime : 13ms)