Jump to content

Chat with mysql?


blackcell

Recommended Posts

Is it a good idea to use a database for a chat script? To store the messages and so on? I don't know if there would be issues with multiple users trying to access the data at once.  I wrote a simple chat script and it works great if two people use it. I just don't know how it will perform with hundreds even thousands chatting at once, accessing the same db table.

 

I use xajax to display the chat log so it you can count on every user sending a query every 1000 ms or 1 second.  Could this cause problems?

 

Thanks in advance.

Link to comment
Share on other sites

I don't think so. Personally I wouldn't be a happy camper if I learned some chat server was logging my conversations. This option should instead be left to the users and only to save the history on their own computers if they so wish. As you guess, that's javascript.

 

User management is one of the few things you will need a database for, concerning chat servers.

Link to comment
Share on other sites

Is it a good idea to use a database for a chat script? To store the messages and so on? I don't know if there would be issues with multiple users trying to access the data at once.  I wrote a simple chat script and it works great if two people use it. I just don't know how it will perform with hundreds even thousands chatting at once, accessing the same db table.

 

I use xajax to display the chat log so it you can count on every user sending a query every 1000 ms or 1 second.  Could this cause problems?

 

Thanks in advance.

 

 

 

I've done this on low scale chat boxes and it doesn't blow up but it did get laggy after 10 concurrent users.

 

The new approach to our chat system is a socket system which results in an indirect storage method if you want to record chat logs.

Link to comment
Share on other sites

Well actually I don't even want to record. I am looking for the best method of doing it.

 

To expand more, I am creating a "plug-in" type script using an inline frame. The main target is a turn based php game. I need to make this to where it will only return chat history from current time entered to the time you left a certain location.  So I want to have it to where chat history is kept for the user and when the user moves into a new region, they keep their history and start to receive chat from the region they are in.

 

This is my first attempt at making a chat script by the way.

Link to comment
Share on other sites

I'm not understanding sockets very well. Actually I just can't find a good example because I don't know what to look for. I see people doing stuff with sockets but not chat implementation or anything I can relate to.

 

It would be easier if you had a C background :)

 

Sockets in PHP is in my opinion one of the most powerful extensions of the language. It allows you to connect to services other than http. Imagine being able to access a ftp server or usenet groups through a web browser, for instance. More important, you can also act as a server providing differentiated services that may or not be accessible through a web browser (remember, PHP is also for the console).

 

In a nutshell that is what the sockets extension allows you to do. Despite it's apparent small size (25 functions and a similar number of constants) this extension really puts the world in your hands. Look at the control panel of your web host. I'm pretty much sure a lot of what you see there is done through sockets.

Link to comment
Share on other sites

I am taking C at college now but haven't got into much of anything besides arithmetic and changing output/input Also the graphical presentation of what I know how to do in C is unappealing. In other words I don't know much about manipulating the graphical side of C yet.

 

Do you have any good resource recommendations on learning sockets in php? Everything I have seen is usually in linux and makes no sense as to what they are doing (to me)

Link to comment
Share on other sites

the socket is all about getting data from Point A->B not about presentation you take that raw data i.e the message and pretty it up.

You ain't working in the command line of your intro to C class.  The presentation is full html levels its just how you pass strings from User A to User B.

 

Look up sockets they aren't terribly hard and php sockets are pretty will defined in the manual

 

http://us.php.net/manual/en/function.socket-connect.php is a good start

http://us.php.net/manual/en/ref.sockets.php General info

 

Once you get the basic ideas you can post back your script and we can explain it more, but I'm not going to sit down and write you socket script for you.

 

 

Link to comment
Share on other sites

You ain't working in the command line of your intro to C class. 

 

I'm not using VS2008, or anything else. I connect to a unix term server, write the source with pico, compile it on the server and everything is a black background with white letters (imagine the dos window). If that isn't command line what is it (<--Serious Question)?

 

Thanks for the resources.

Link to comment
Share on other sites

i would use a database if that lags as the guy said i would use a fopen fwrite etc on an XML file and then use the browser javas cript ajax to keep the XML file live updated., use cron to zero the file with php at teh end of teh day of whatever, in ur ajax on the frontend use php to read the xml called by javascript then php should be able to only look at messages that are no older than the time that user loged in so it would seem as if they start flowing in.

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.