blackcell Posted April 7, 2008 Share Posted April 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
quiettech Posted April 7, 2008 Share Posted April 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted April 7, 2008 Share Posted April 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 7, 2008 Author Share Posted April 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted April 7, 2008 Share Posted April 7, 2008 look around on the forum but you can do it with sockets fairly easily using mysql to backend it partially. I am actually working with someone who is doing it in flash and sending through sockets via php Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 7, 2008 Author Share Posted April 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
quiettech Posted April 7, 2008 Share Posted April 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 8, 2008 Author Share Posted April 8, 2008 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) Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted April 8, 2008 Share Posted April 8, 2008 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. Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 8, 2008 Author Share Posted April 8, 2008 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. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted April 8, 2008 Share Posted April 8, 2008 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. Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 8, 2008 Author Share Posted April 8, 2008 I need to learn about xml also lol. Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 8, 2008 Author Share Posted April 8, 2008 I found this, which is an excellent explanation to someone like me. http://www.litfuel.net/tutorials/sockets/sockets.php Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 8, 2008 Author Share Posted April 8, 2008 Can anybody better explain: #!/usr/bin/php -q Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.