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. :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.