Text Chatting after logging in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Text Chatting after logging in

Post by kkonline »

Hi,
I am working on an application for which the registered users who have logged on (say A) should be able to chat with another person (say B) when A visits the profile of B.

Till now i am completed the user management system using session and as a programmer i know if A and B have logged in next I want to allow chat between then (similar to gmail perhaps) what should be the logic approach ?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You could mark a field in the database as "logged_in" for each user so you know who's logged in. Then for the chat you'll probably want to use AJAX and put messages into a temporary table. It's far too complex to simply post code here for but the logic I'd take would be something like:

1. Generate a unique "chat_id" based on all users involved in the chat.
2. Put messages into a table "chat_conversation" or similar.
3. Use AJAX to keep requesting a lookup of new messages where the chat_id matches the current chat.
Post Reply