Hello Great developers,

i am working on an application, where i am trying to implement the multiple users chat,
Basically the users send message to mobile and then get back the reply , then it shows like normal chatting.

all everything is working and GREAT :icon_wink:

But Except the multiple users chat at a time, So some advance queries and script handeling required,

So please come on, and give some cool replies,

I know you can do it..


Waiting for your replies////

You haven't asked a question.

Member Avatar

Show us yer code maestro. You show us yours and we'll show you ours.


Thanks dude for the reply, my question is , That how i can handle multiple users chatting at a time, on the screen, this is little bit difficult.


thank you,

i think i need the concept that how i can handle mutiple users chat, i don't think that for this you need the code, the code i have is just for one user chat at a time.


hope you can understand now,

You can try to get the concept to continue your chatting.

Member Avatar

Is this php? You doing it via webpage? All you need is ajax polling. However, I assume that this would be quite slow on a mobile.

You have a db or file for that matter. A js script polls the db/file via ajax, say once every 5-10 seconds (setInterval should do it). An updatable div then adds the new messages - if there are any. Should be simple, if js is enabled on users' phones.


its nice one reply till i posted, i have the same methodology for the single user, i refresh the div with jquery interval script, but i want to handle multiple users replies and chatting boxes on the screen,

Means how i will jugde from the database that there is a new reply for this user, is there anyway that i fire ajax on entery in the database,

i think it is little bit simple now,


Member Avatar

If you want to set up multiple chats as opposed to a single chat with multiple users, you just have a chatbox id (with a name provided by the first user) in a table. Registered users then choose a chatbox to join. Their posts are then entered with a chatbox id in the messages table.

chatbox table
chatbox_id (PK, int)
chatbox_name (varchar)
creator_id (foreign key = user_id, int)
created_on (datetime - unix integer, int)
chatbox_type (e.g. public, by invitation)
join_key (if by invitation - this key can be sent to specified recipients)
description (text or varchar)

messages table
message_id (PK, int)
user_id (foreign_key, int)
chatbox_id (foreign key, int)
message (text OR varchar if limiting to 255 charcaters)
time_entered (datetime - unix integer, int)

users table
user_id (PK, int)
email (varchar) [optional]
username [can be guest but must be unique if not logged in]
password (varchar - should be hashed, e.g. md5)

You could make this DB more complicated like adding user session data, but the above should work. There needs to be quite a bit of php session handling going on to keep track of which chatbox_id/user_id is being added to sql queries.

Also, to avoid your db getting humungously large, you should have a cron job that clears messages older than a specified age.

Member Avatar

Sorry re-read your post. If you want to avoid polling the DB at regular intervals (ajax) and only get something to the client when the db gets a new entry, you'll need something called 'comet'. This is also known as 'long-polling' or 'push'. It's not for the faint hearted, but you may get some joy from the APE project. Google 'ape project'.


your replies are very good, and very helpful to yet, if you can add some more specification, then you are welcome.

Thanks again

Member Avatar

The APE/Comet thing will only work if you can place a comet server on the machine that runs the chat app. It must be Linux/Mac - no windows. Talk to your host to see what they say. I assume they wouldn't be overly happy with this somehow.

Short of leading you through it step by step, I'm afraid that's all the help I can give. This is a 'help' not a 'free coder-for-hire' site after all. Good luck though.