views:

81

answers:

4

Hello. I have a web site where users register to access the content of the web site. I want to create a chat like Facebook. So when a user clicks on a button called "CHAT," it displays a list of users that are online, and so he can chat with other users. Please give me a suggestion how to create a chat like this in AJAX and jQuery. Please help me.

A: 

One way could be to use a java/javascript irc client and set up a channel for your site

kskjon
+1  A: 

Meebo rooms might be the easiest way:

http://www.meebo.com/rooms/

Slater
A: 

with PHP and ajax, you will have to store the chat on the server, e.g. in a mysqltable with this columns:

id
from_user
to_user
time
message
read

If a user writes a message, it will be written in the table by a ajax request.

To recieve a message you need to send requests to the server permanently where you ask whether there are new messages for actual user which are not read, send them to the user and mark as read(eg with timestamp, so you can delete history after one week if read),

Tokk
A: 
  • Using google I found for example this tutorial to create dcfhat using jquery/php. It does use polling so it isn't really realtime and you server can not cope on high load(100+ connections or something).
  • You could integrate something like speeqe on your site.
  • it would be best to write something like this using http-streaming/long-polling, but this can't be done efficiently in php. Java has a real nice library to do this called atmosphere
Alfred