Jump to content

[SOLVED] what are good practices for php/mysql/ajax chat (specific questions listed)


ultrus

Recommended Posts

Hello,

I decided to make a make a chat layer (not a pop-up window or separate page) on my website that visitors can activate at any time while visiting a page. This will be for instant customer support. The visitor makes up a username, and we start chatting from there. I plan to use css, javascript/ajax, php, and mysql. With that said, here are a few questions:

 

1. Using mysql, what kind of things should I be tracking durring an open chat like this? I'm thinking timestamp, ip address, nickname A, nickname B, support contact id, message

 

2. Since ajax will be used to get the latest chat content, should I load all chat content every couple seconds, or is there a method that would allow appending only the latest chat messages? One alternative would be to load in the last 15 chat messages every couple seconds. On the other hand, I would like to keep everything there for the visitor's reference. Any thoughts on keeping the load time brief?

 

3. One idea of keeping load amount reduced is to have an ajax check comparing timestamps, and only load chat when timestamps don't match.

 

4. I imagine there will be security involved. So far I'm thinking ip block, profanity checks, message cleanup on php end (do I need to do a javascript parse first?), and ip logging. Any additional ideas?

 

5. What happens when more than one person wants to chat with me at the same time? How would I go about creating a waiting list, or an updating message for the visitor saying that I'm with an other person and will be with them soon? This is where I am stuck the most.

 

Thanks in advance for the feedback! I think I'm heading in the right direction, but could use any good advise. :)

Hmm. I think I have it figured out. I just needed sleep.

 

1. Using mysql, what kind of things should I be tracking durring an open chat like this? I'm thinking timestamp, ip address, nickname A, nickname B, support contact id, message

More or less, this will work, with more work on the support side of chat.

 

2. Since ajax will be used to get the latest chat content, should I load all chat content every couple seconds, or is there a method that would allow appending only the latest chat messages? One alternative would be to load in the last 15 chat messages every couple seconds. On the other hand, I would like to keep everything there for the visitor's reference. Any thoughts on keeping the load time brief?

Timestamps will be compared, and the latest content will be appended to the chat window, only loading small amounts of chat at a time.

 

3. One idea of keeping load amount reduced is to have an ajax check comparing timestamps, and only load chat when timestamps don't match.

 

4. I imagine there will be security involved. So far I'm thinking ip block, profanity checks, message cleanup on php end (do I need to do a javascript parse first?), and ip logging. Any additional ideas?

Html will be allowed, but malicious tags will be stripped. Other filters will be placed for increased security.

 

5. What happens when more than one person wants to chat with me at the same time? How would I go about creating a waiting list, or an updating message for the visitor saying that I'm with an other person and will be with them soon? This is where I am stuck the most.

For now, the support person will only chat with one person at a time, and can set availability which will open up opportunities for waiting to chat.

 

That's about it. Thanks for letting me ramble. Sometimes I just need to write things down for it to make sense.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.