TheWandererLee Posted January 23, 2007 Share Posted January 23, 2007 I am trying to get into creating online games with PHP but am having serious trouble. I've looked everywhere and can't seem to find the answer. All I want to be able to do for now is create a simple chat client using PHP and a combination of something else (preferrably flash). I've searched for a while and all I really seem to know is that I'm going to be doing either alot with socket connections, or MySQL databases, or both, but I'm really unsure at how to go about doing this. All I would like is a simple online chat system (that is real-time) please help :'(-Lee Quote Link to comment Share on other sites More sharing options...
Tandem Posted January 23, 2007 Share Posted January 23, 2007 You can't make a real time chat feature with just php. I'm not sure about combining with other language, but not with 100% php.You can make forums, with php, but that's about as close as your going to get i'm afraid. Quote Link to comment Share on other sites More sharing options...
TheWandererLee Posted January 23, 2007 Author Share Posted January 23, 2007 Is it possible, to open a socket connection with PHP and keep it open so I can program a client in Adobe Flash or some other language to connect to it and send data between the users connected in real-time? if so, how? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 23, 2007 Share Posted January 23, 2007 I did a small chat using PHP and Ajax from script.aculo.us Quote Link to comment Share on other sites More sharing options...
TheWandererLee Posted January 23, 2007 Author Share Posted January 23, 2007 I'm not experienced in AJAX though :( could you link me to a tutorial on how to do it through AJAX or to the source of how you made a chat application with it. (for the record I've never heard of AJAX though :o so if there is another way...) Quote Link to comment Share on other sites More sharing options...
gloveny Posted January 23, 2007 Share Posted January 23, 2007 I have made a semi real-time php chat room purely from PHP and mysql, but I don’t use it as I also made one from Java Which is very real time.lol. PHP / MySQL--I would NOT recommend this method for large scale projects--Have a framed window, Main frame contains chat room output text area, plus input text field and a button for saying stuff. The second frame has a page refresh. Mine had a refresh rate of 5 seconds (very unreal time).This refreshing window holds the ID of the last message it got from the database. Each time is refreshes it passes this ID to the server and only gets messages that are after this ID number. So it never gets duplicate messages. When the pages refreshes with the new message it uses JavaScript to pump the messages into the chat room output text area. If you say something make a third unseen frame refresh with the data sent to the server to add to the database. The next time your browser refreshes you will collect all new messages plus your own. The message will be in the right order, but will come in chunks (how ever many seconds you set the refresh rate). Each time the server is hit by a message request, it deletes all messages that are 30 seconds old to save space on the server. Since your refresh rate is only 5 seconds you won’t loss any messages.Mine even had PVT facilities, so if you double clicked a name you opened a private window on either side of the conversation. But, about 6 months ago my laptop failed and I lost all my work including two years worth of a website project, which included this chat room. It was very basic though and I urge who ever wants to do one to do it as it isn’t as hard as you think. And they are worthy contestants against real-time Java apps if you can’t afford or have the know how to get a Java one.I also made one form Java which works extremely well (when tested with 2 people , lol) haven’t had a chance to test it with more :(So anyway, you CAN make a php chat room and they CAN be very good. Just take the time to implement all the functionality that you would expect from a chat room and you can’t go wrong.All the best, Graham Vincent 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.