/    Sign up×
Community /Pin to ProfileBookmark

AJAX Chat Help/Advice

I don’t exactly need some corrections on code. My code is probably 99% errorless.

I would like some help. Maybe some links to tutorials or concepts that I could put to use.

You see, I wrote my own AJAX chat, but there is a large problem with it. It is a resource hog, therefore isn’t suitable for anything other than a home server, as professional webhost can’t have one particular user using double digit percents of their resources at any given time.

If someone has personal advice, I’ll explain my chat briefly. I have looked at other chats(well, just a few AJAX ones), and when I designed mine, I wanted to include something very important. If I join the chat, I don’t want to see any messages that were sent before I joined. At first I had one file to hold the entire chat, but then a user might join and have an hour long conversation brought up. Some chats though limit the file size so you can only have so much info on the screen(but then you lose information in your chat, which isn’t what I wanted).
So essentialy, I have a file that holds user, and then each user has their own chat file. When you login, you are added to the list. Now every time someone sends a message, it loads that user list into an array. Each person on the list has their chat file opened, and the information is sent. When you logout, your name is removed and so is your file.

Of course this is horrible from a webhost end. Every 5 seconds I refresh, which requires the user file to be opened, and then the userlist is refreshed right after. So that is 2 file operations every 5 seconds, per user. Now if I send a message, it opens each user file, and so that is dependent upon the number of users, but even if I have 5 users, you can easily add this up and within a 20 minute time period, we have basically be reading and writing all over the place.

Yes, I use text files as I am still new to PHP, so this limited my ability to write any complex AJAX scripts. I would like to learn more, but of course I need to know where to find the help.

I would assume using something like a database would help greatly, as this is one file that is opened and written to, rather than a large number of files.

Is there anything anyone can tell me? Any places to go for good tutorials or help?

Thanks in advance.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CuppyTeaDec 11.2008 — A database will solve your problems.

http://w3schools.com offer tutorials on setting up and configuring MySQL databases.

Hope it helps...
×

Success!

Help @Sup3rkirby spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...